require "language/go" class Pilosa < Formula desc "Distributed bitmap index that queries across data sets" homepage "https://www.pilosa.com" url "https://github.com/pilosa/pilosa/archive/v0.6.0.tar.gz" sha256 "6121066051ab55f266f2c891edcc66d449aa5786c8622f7f765015806ee6f84f" bottle do cellar :any_skip_relocation sha256 "856bcbf157d4374c259e20fd5b0afa7cc0faa0d340b2a8fc77a61cf4a7d820ad" => :sierra sha256 "ddca7e8a0ace058776208d9f52332f760521fb5426362f57382e24a2e07cc3ab" => :el_capitan sha256 "66c4f85b6f05e5873787a48a3665c0dcfe361dd2ab60ce3fdec44d9634bcac6d" => :yosemite end depends_on "go" => :build depends_on "dep" => :build go_resource "github.com/rakyll/statik" do url "https://github.com/rakyll/statik.git", :revision => "25d6cab4d68d2a9b7c5965aa381726dd5dd6d7b8" end def install ENV["GOPATH"] = buildpath ENV.prepend_path "PATH", "#{buildpath}/bin" (buildpath/"src/github.com/pilosa/pilosa").install buildpath.children Language::Go.stage_deps resources, buildpath/"src" cd "src/github.com/rakyll/statik" do system "go", "install" end cd "src/github.com/pilosa/pilosa" do system "make", "generate-statik", "pilosa", "FLAGS=-o #{bin}/pilosa", "VERSION=#{version}" end end plist_options :manual => "pilosa server" def plist; <<-EOS.undent Label #{plist_name} ProgramArguments #{opt_bin}/pilosa server RunAtLoad KeepAlive SuccessfulExit WorkingDirectory #{var} EOS end test do begin server = fork do exec "#{bin}/pilosa", "server" end sleep 0.5 assert_match("Welcome. Pilosa is running.", shell_output("curl localhost:10101")) assert_match("", shell_output("curl --user-agent NotCurl localhost:10101")) ensure Process.kill "TERM", server Process.wait server end end end