homebrew-core/Formula/cayley.rb
2019-10-15 17:48:35 -04:00

90 lines
2.7 KiB
Ruby

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 "ef95f5188624ab0af351c03552e5e3b715e0747d9117fd3c235f5219e7347051" => :catalina
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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/cayley</string>
<string>http</string>
<string>--config=#{etc}/cayley.conf</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>#{var}/cayley</string>
<key>StandardErrorPath</key>
<string>#{var}/log/cayley.log</string>
<key>StandardOutPath</key>
<string>#{var}/log/cayley.log</string>
</dict>
</plist>
EOS
end
test do
assert_match version.to_s, shell_output("#{bin}/cayley version")
end
end