90 lines
2.9 KiB
Ruby
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.1.tar.gz"
|
|
sha256 "057ba3256b85d45ea3d85d258142e3ff887ec595518bdd4500a0d91379c1183f"
|
|
head "https://github.com/google/cayley.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "a0781fdda63582918522cb99808c769e5900ff8a0000d285f4a39d8ae3b0ebf8" => :high_sierra
|
|
sha256 "63813aee1519605e78c4e7b6700f6891798836f5c4d10f5aa99f2235f5da8319" => :sierra
|
|
sha256 "e4c996ce89c878f8df88205775126da0c8658caa96bf25750d4c007a78e4e807" => :el_capitan
|
|
end
|
|
|
|
option "without-samples", "Don't install sample data"
|
|
|
|
depends_on "bazaar" => :build
|
|
depends_on "mercurial" => :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
|