class NatsStreamingServer < Formula desc "Lightweight cloud messaging system" homepage "https://nats.io" url "https://github.com/nats-io/nats-streaming-server/archive/v0.2.2.tar.gz" sha256 "741d03db1f78c348856476b0b27f39c391a6695aa6c199997a517e6f8c0e58f1" head "https://github.com/nats-io/nats-streaming-server.git" bottle do cellar :any_skip_relocation sha256 "0b2428afbf8d52bbeedb6fb87277df0a6cca05887b85ed55d09ea361b85d3095" => :el_capitan sha256 "fbe77a3a8c7ff7d2a04f27cb9fc048c26ff1188c3c6b038a8d92ccc65ca729a6" => :yosemite sha256 "8b98ed9cf49e01e79c9ddd5fc1fdbdcacfda16a90a628a901c34aecbb4385004" => :mavericks end depends_on "go" => :build def install ENV["GOPATH"] = buildpath mkdir_p "src/github.com/nats-io" ln_s buildpath, "src/github.com/nats-io/nats-streaming-server" buildfile = buildpath/"src/github.com/nats-io/nats-streaming-server/nats-streaming-server.go" system "go", "build", "-v", "-o", bin/"nats-streaming-server", buildfile end plist_options :manual => "nats-streaming-server" def plist; <<-EOS.undent Label #{plist_name} ProgramArguments #{opt_bin}/nats-streaming-server RunAtLoad EOS end test do pid = fork do exec "#{bin}/nats-streaming-server --port=8085 --pid=#{testpath}/pid --log=#{testpath}/log" end sleep 3 begin assert_match "INFO", shell_output("curl localhost:8085") assert File.exist?(testpath/"log") assert_match version.to_s, File.read(testpath/"log") ensure Process.kill "SIGINT", pid Process.wait pid end end end