aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJeremy Whitlock2014-07-07 17:43:44 -0600
committerMike McQuaid2014-07-08 11:05:11 -0700
commit1bd2fb2a61c7101a8c79c05afc90eeb02e9aa240 (patch)
treef12877974b7b03886daed3d4333ac016a83b4b95 /Library
parentd19f3bdb80f443029b6cd88a7223f9bb58fa07ac (diff)
downloadhomebrew-1bd2fb2a61c7101a8c79c05afc90eeb02e9aa240.tar.bz2
cayley 0.3.0 (new formula)
Diffstat (limited to 'Library')
-rw-r--r--Library/Formula/cayley.rb116
1 files changed, 116 insertions, 0 deletions
diff --git a/Library/Formula/cayley.rb b/Library/Formula/cayley.rb
new file mode 100644
index 000000000..72334395b
--- /dev/null
+++ b/Library/Formula/cayley.rb
@@ -0,0 +1,116 @@
+require "formula"
+
+class Cayley < Formula
+ homepage "https://github.com/google/cayley"
+ url "https://github.com/google/cayley/archive/v0.3.0.tar.gz"
+ sha1 "b69b1da6854cf174854034061ab0919fcf0c18b8"
+ head "https://github.com/google/cayley.git"
+
+ depends_on "bazaar" => :build
+ depends_on :hg => :build
+ depends_on "go" => :build
+
+ option "without-samples", "Disable installing sample data"
+
+ def install
+ # Prepare for Go build
+ ENV["GOPATH"] = buildpath
+
+ # To avoid re-downloading Cayley, symlink its source from the tarball so that Go can find it
+ mkdir_p "src/github.com/google/"
+ ln_s buildpath, "src/github.com/google/cayley"
+
+ # Install Go dependencies
+ system "go", "get", "github.com/badgerodon/peg"
+ system "go", "get", "github.com/barakmich/glog"
+ system "go", "get", "github.com/julienschmidt/httprouter"
+ system "go", "get", "github.com/petar/GoLLRB/llrb"
+ system "go", "get", "github.com/robertkrimen/otto"
+ system "go", "get", "github.com/russross/blackfriday"
+ system "go", "get", "github.com/syndtr/goleveldb/leveldb"
+ system "go", "get", "github.com/syndtr/goleveldb/leveldb/cache"
+ system "go", "get", "github.com/syndtr/goleveldb/leveldb/iterator"
+ system "go", "get", "github.com/syndtr/goleveldb/leveldb/opt"
+ system "go", "get", "github.com/syndtr/goleveldb/leveldb/util"
+ system "go", "get", "labix.org/v2/mgo"
+ system "go", "get", "labix.org/v2/mgo/bson"
+
+ # HEAD does not require the extra work to get 0.3.0 to build properly so avoid it
+ unless build.head?
+ # Install Go dependencies
+ system "go", "get", "github.com/stretchrcom/testify/mock"
+
+ # Fix issue where 0.3.0 builds againsts an old version of syndtr/goleveldb
+ inreplace "graph/leveldb/leveldb_triplestore.go", "GetApproximateSizes", "SizeOf"
+ end
+
+ # Build
+ system "go", "build", "-o", "cayley"
+
+ # Create sample configuration that uses the Homebrew-based directories
+ inreplace "cayley.cfg.example", "/tmp/cayley_test", "#{var}/cayley/data.nt"
+
+ # Install binary and configuration
+ bin.install "cayley"
+ etc.install "cayley.cfg.example" => "cayley.conf"
+
+ # Create data directory
+ (var/"cayley").mkpath
+
+ if build.with? "samples"
+ system "gzip", "-d", "30kmoviedata.nt.gz"
+
+ # Copy over sample data
+ (share/'cayley/samples').install "testdata.nt"
+ (share/'cayley/samples').install "30kmoviedata.nt"
+ end
+ end
+
+ plist_options :manual => "cayley --config=#{HOMEBREW_PREFIX}/etc/cayley.conf"
+
+ def plist; <<-EOS.undent
+ <?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>--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
+ require 'open3'
+
+ touch "test.nt"
+
+ Open3.popen3("#{bin}/cayley", "repl", "--dbpath=#{testpath}/test.nt") do |stdin, stdout, _|
+ stdin.write "graph.Vertex().All()"
+ stdin.close
+
+ result = stdout.read.strip
+
+ assert !result.include?("Error:")
+ assert result.include?("Elapsed time:")
+ end
+ end
+end