class Cayley < Formula desc "Graph database inspired by Freebase and Knowledge Graph" homepage "https://github.com/cayleygraph/cayley" url "https://github.com/cayleygraph/cayley.git", :tag => "v0.7.7", :revision => "dcf764fef381f19ee49fad186b4e00024709f148" bottle do cellar :any_skip_relocation sha256 "e647be34623b1a8d635df7508f09111dfd8eb6f368a6979f9c5619b016beda8c" => :mojave sha256 "4177fdcb60422d484f1377e5367844ebcc9be471fffc76e717d8ad90e49ee99c" => :high_sierra end depends_on "bazaar" => :build depends_on "go" => :build depends_on "mercurial" => :build def install ENV["GOPATH"] = buildpath dir = buildpath/"src/github.com/cayleygraph/cayley" dir.install buildpath.children cd dir do commit = Utils.popen_read("git rev-parse --short HEAD").chomp ldflags = %W[ -s -w -X github.com/cayleygraph/cayley/version.Version=#{version} -X github.com/cayleygraph/cayley/version.GitHash=#{commit} ] system "go", "build", "-o", bin/"cayley", "-ldflags", ldflags.join(" "), ".../cmd/cayley" inreplace "cayley_example.yml", "./cayley.db", var/"cayley/cayley.db" etc.install "cayley_example.yml" => "cayley.yml" # 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 --config=#{HOMEBREW_PREFIX}/etc/cayley.conf" def plist; <<~EOS KeepAlive SuccessfulExit Label #{plist_name} ProgramArguments #{opt_bin}/cayley http --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