diff --git a/extras/httpie.rb b/extras/httpie.rb new file mode 100644 index 00000000..820e8d31 --- /dev/null +++ b/extras/httpie.rb @@ -0,0 +1,47 @@ +# The latest Homebrew formula as submitted to Homebrew/homebrew-core. +# Only useful for testing until it gets accepted by homebrew maintainers. +# +# https://github.com/Homebrew/homebrew-core/blob/master/Formula/httpie.rb +# +class Httpie < Formula + desc "User-friendly cURL replacement (command-line HTTP client)" + homepage "https://httpie.org/" + + url "https://pypi.python.org/packages/10/cf/da63860ef92f9c90a5bd684d5f162067b26ef113b1c4afb9979c2f5c5a7a/httpie-0.9.7.tar.gz" + sha256 "6427c198c80b04e84963890261f29f1e3452b2b4b81e87a403bf22996754e6ec" + + head "https://github.com/jkbrzt/httpie.git" + + depends_on :python3 + + resource "requests" do + url "https://pypi.python.org/packages/d9/03/155b3e67fe35fe5b6f4227a8d9e96a14fda828b18199800d161bcefc1359/requests-2.12.3.tar.gz" + sha256 "de5d266953875e9647e37ef7bfe6ef1a46ff8ddfe61b5b3652edf7ea717ee2b2" + end + + resource "pygments" do + url "https://pypi.python.org/packages/b8/67/ab177979be1c81bc99c8d0592ef22d547e70bb4c6815c383286ed5dec504/Pygments-2.1.3.tar.gz" + sha256 "88e4c8a91b2af5962bfa5ea2447ec6dd357018e86e94c7d14bd8cacbc5b55d81" + end + + def install + pyver = Language::Python.major_minor_version "python3" + ENV.prepend_create_path "PYTHONPATH", libexec/"vendor/lib/python#{pyver}/site-packages" + %w[pygments requests].each do |r| + resource(r).stage do + system "python3", *Language::Python.setup_install_args(libexec/"vendor") + end + end + + ENV.prepend_create_path "PYTHONPATH", libexec/"lib/python#{pyver}/site-packages" + system "python3", *Language::Python.setup_install_args(libexec) + + bin.install Dir["#{libexec}/bin/*"] + bin.env_script_all_files(libexec/"bin", :PYTHONPATH => ENV["PYTHONPATH"]) + end + + test do + raw_url = "https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/httpie.rb" + assert_match "PYTHONPATH", shell_output("#{bin}/http --ignore-stdin #{raw_url}") + end +end