47 lines
1.3 KiB
Ruby
47 lines
1.3 KiB
Ruby
class Mockserver < Formula
|
|
desc "Mock HTTP server and proxy"
|
|
homepage "https://www.mock-server.com/"
|
|
url "https://oss.sonatype.org/content/repositories/releases/org/mock-server/mockserver-netty/5.11.2/mockserver-netty-5.11.2-brew-tar.tar"
|
|
sha256 "1758bb80c3e5cd250b55757a53105db7b03ff1b05d2dfca501ce5795feff8756"
|
|
license "Apache-2.0"
|
|
|
|
livecheck do
|
|
url "https://oss.sonatype.org/content/repositories/releases/org/mock-server/mockserver-netty/"
|
|
regex(%r{href=.*?v?(\d+(?:\.\d+)+)/?["' >]}i)
|
|
end
|
|
|
|
bottle :unneeded
|
|
|
|
depends_on "openjdk"
|
|
|
|
def install
|
|
inreplace "bin/run_mockserver.sh", "/usr/local", HOMEBREW_PREFIX
|
|
libexec.install Dir["*"]
|
|
(bin/"mockserver").write_env_script libexec/"bin/run_mockserver.sh", JAVA_HOME: Formula["openjdk"].opt_prefix
|
|
|
|
lib.install_symlink "#{libexec}/lib" => "mockserver"
|
|
|
|
mockserver_log = var/"log/mockserver"
|
|
mockserver_log.mkpath
|
|
|
|
libexec.install_symlink mockserver_log => "log"
|
|
end
|
|
|
|
test do
|
|
port = free_port
|
|
|
|
mockserver = fork do
|
|
exec "#{bin}/mockserver", "-serverPort", port.to_s
|
|
end
|
|
|
|
loop do
|
|
Utils.popen_read("curl", "-s", "http://localhost:#{port}/status", "-X", "PUT")
|
|
break if $CHILD_STATUS.exitstatus.zero?
|
|
end
|
|
|
|
system "curl", "-s", "http://localhost:#{port}/stop", "-X", "PUT"
|
|
|
|
Process.wait(mockserver)
|
|
end
|
|
end
|