55 lines
1.6 KiB
Ruby
55 lines
1.6 KiB
Ruby
class Imgproxy < Formula
|
|
desc "Fast and secure server for resizing and converting remote images"
|
|
homepage "https://imgproxy.net"
|
|
url "https://github.com/imgproxy/imgproxy/archive/v2.15.0.tar.gz"
|
|
sha256 "3bee2aecbb66c98c9e1254a163fb53e32e8af5bf8e3a92f119427113bee01c91"
|
|
license "MIT"
|
|
head "https://github.com/imgproxy/imgproxy.git"
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "d61664f7b13e4a2e87d37f381cc0a84d050ac32cec6f47ccccf0e7eeca8d5a99" => :catalina
|
|
sha256 "052202adba0cdb507093e8f0d433aa95623875d56579d3e2a45297e4cfe112bd" => :mojave
|
|
sha256 "5b9b32c0fa5bd4843b6d167ed8db8e1e665f9967b4694b06f50492f8f7d3c37a" => :high_sierra
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
depends_on "pkg-config" => :build
|
|
depends_on "vips"
|
|
|
|
def install
|
|
ENV["CGO_LDFLAGS_ALLOW"]="-s|-w"
|
|
ENV["CGO_CFLAGS_ALLOW"]="-Xpreprocessor"
|
|
|
|
system "go", "build", *std_go_args
|
|
end
|
|
|
|
test do
|
|
port = free_port
|
|
|
|
cp(test_fixtures("test.jpg"), testpath/"test.jpg")
|
|
|
|
ENV["IMGPROXY_BIND"] = "127.0.0.1:#{port}"
|
|
ENV["IMGPROXY_LOCAL_FILESYSTEM_ROOT"] = testpath
|
|
|
|
pid = fork do
|
|
exec bin/"imgproxy"
|
|
end
|
|
sleep 10
|
|
|
|
output = testpath/"test-converted.png"
|
|
|
|
system "curl", "-s", "-o", output,
|
|
"http://127.0.0.1:#{port}/insecure/fit/100/100/no/0/plain/local:///test.jpg@png"
|
|
assert_equal 0, $CHILD_STATUS
|
|
assert_predicate output, :exist?
|
|
|
|
file_output = shell_output("file #{output}")
|
|
assert_match "PNG image data", file_output
|
|
assert_match "1 x 1", file_output
|
|
ensure
|
|
Process.kill("TERM", pid)
|
|
Process.wait(pid)
|
|
end
|
|
end
|