homebrew-core/Formula/cayley.rb
2017-12-25 00:45:24 -08:00

90 lines
2.9 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/archive/v0.7.0.tar.gz"
sha256 "d78970997d2c23991c11d5a06e266d4421a9f175e8364dc6a094308489882314"
head "https://github.com/google/cayley.git"
bottle do
cellar :any_skip_relocation
sha256 "192570b3e952d0697624b5315348892be330923bdc12b57dafc8b59ce8197983" => :high_sierra
sha256 "c558ffdc02dfae52b0dee74b9de1b3b81bf19bebd9459ad1ee529e4ffb4a6623" => :sierra
sha256 "14b1f7f81db724c6929e52d9dee0786943fbe23d48ef05f1b8cbd20ec62c3515" => :el_capitan
end
option "without-samples", "Don't install sample data"
depends_on "bazaar" => :build
depends_on :hg => :build
depends_on "glide" => :build
depends_on "go" => :build
def install
ENV["GOPATH"] = buildpath
ENV["GLIDE_HOME"] = HOMEBREW_CACHE/"glide_home/#{name}"
(buildpath/"src/github.com/cayleygraph/cayley").install buildpath.children
cd "src/github.com/cayleygraph/cayley" do
system "glide", "install"
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"
if build.with? "samples"
system "gzip", "-d", "data/30kmoviedata.nq.gz"
(pkgshare/"samples").install "data/testdata.nq", "data/30kmoviedata.nq"
end
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
<?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>--assets=#{opt_pkgshare}/assets</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