class Cayley < Formula desc "Graph database inspired by Freebase and Knowledge Graph" homepage "https://github.com/cayleygraph/cayley" url "https://github.com/cayleygraph/cayley/archive/v0.7.5.tar.gz" sha256 "4fcc8bf44f775dbbbd6146713f6fbdc80f2d88e2e8b93767f62eb5d635a56739" head "https://github.com/google/cayley.git" bottle do cellar :any_skip_relocation sha256 "377e5180df5cf802155e5d2af615f226706c0f02774b50a53b2b5d44480a151d" => :mojave sha256 "ce7a9c57fbf969e0cf60bc9cdf8f6e1d57e254dc506a9e509cc4d7052bbb53df" => :high_sierra sha256 "a745c0d7c87f43e62232be852ec8df3b8ee5e18cb6595725b5588843521164a4" => :sierra end depends_on "bazaar" => :build depends_on "dep" => :build depends_on "go" => :build depends_on "mercurial" => :build def install ENV["GOPATH"] = buildpath (buildpath/"src/github.com/cayleygraph/cayley").install buildpath.children cd "src/github.com/cayleygraph/cayley" do system "dep", "ensure", "-vendor-only" system "go", "build", "-o", bin/"cayley", "-ldflags", "-X main.Version=#{version}", ".../cmd/cayley" inreplace "cayley_example.yml", "./cayley.db", var/"cayley/cayley.db" etc.install "cayley_example.yml" => "cayley.yml" (pkgshare/"assets").install "docs", "static", "templates" # Install samples system "gzip", "-d", "data/30kmoviedata.nq.gz" (pkgshare/"samples").install "data/testdata.nq", "data/30kmoviedata.nq" end end def post_install unless File.exist? var/"cayley" (var/"cayley").mkpath # Initialize the database system bin/"cayley", "init", "--config=#{etc}/cayley.yml" end end plist_options :manual => "cayley http --assets=#{HOMEBREW_PREFIX}/share/cayley/assets --config=#{HOMEBREW_PREFIX}/etc/cayley.conf" def plist; <<~EOS KeepAlive SuccessfulExit Label #{plist_name} ProgramArguments #{opt_bin}/cayley http --assets=#{opt_pkgshare}/assets --config=#{etc}/cayley.conf RunAtLoad WorkingDirectory #{var}/cayley StandardErrorPath #{var}/log/cayley.log StandardOutPath #{var}/log/cayley.log EOS end test do assert_match version.to_s, shell_output("#{bin}/cayley version") end end