homebrew-core/Formula/datomic.rb
Jérémy Van de Wyngaert 3ebf897cf5 datomic 0.9.5703 (#29165)
2018-06-18 02:23:33 -07:00

83 lines
2.5 KiB
Ruby

class Datomic < Formula
desc "Database separating transactions, storage and queries"
homepage "https://www.datomic.com/"
url "https://my.datomic.com/downloads/free/0.9.5703"
sha256 "22b83d1f2baefaee3e7941ad57df6d77635c3fdbc02a37bdb1cc281d9e7bb3a8"
bottle :unneeded
depends_on :java
def install
inreplace "config/samples/free-transactor-template.properties" do |s|
s.gsub! "# data-dir=data", "data-dir=#{var}/lib/datomic/"
s.gsub! "# log-dir=log", "log-dir=#{var}/lib/datomic/log"
end
# install free-transactor properties
(etc/"datomic").install "config/samples/free-transactor-template.properties" => "free-transactor.properties"
libexec.install Dir["*"]
(bin/"datomic").write_env_script libexec/"bin/datomic", Language::Java.java_home_env
%w[transactor repl repl-jline rest shell groovysh maven-install].each do |file|
(bin/"datomic-#{file}").write_env_script libexec/"bin/#{file}", Language::Java.java_home_env
end
# create directory for datomic data and logs
(var/"lib/datomic").mkpath
end
def post_install
# create directory for datomic stdout+stderr output logs
(var/"log/datomic").mkpath
end
def caveats
<<~EOS
All commands have been installed with the prefix "datomic-".
We agreed to the Datomic Free Edition License for you:
https://my.datomic.com/downloads/free
If this is unacceptable you should uninstall.
EOS
end
plist_options :manual => "transactor #{HOMEBREW_PREFIX}/etc/datomic/free-transactor.properties"
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>Label</key>
<string>#{plist_name}</string>
<key>WorkingDirectory</key>
<string>#{HOMEBREW_PREFIX}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/datomic-transactor</string>
<string>#{etc}/datomic/free-transactor.properties</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardErrorPath</key>
<string>#{var}/log/datomic/error.log</string>
<key>StandardOutPath</key>
<string>#{var}/log/datomic/output.log</string>
</dict>
</plist>
EOS
end
test do
IO.popen("#{bin}/datomic-repl", "r+") do |pipe|
assert_equal "Clojure 1.9.0", pipe.gets.chomp
pipe.puts "^C"
pipe.close_write
pipe.close
end
end
end