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 Label #{plist_name} WorkingDirectory #{HOMEBREW_PREFIX} ProgramArguments #{opt_bin}/datomic-transactor #{etc}/datomic/free-transactor.properties RunAtLoad KeepAlive StandardErrorPath #{var}/log/datomic/error.log StandardOutPath #{var}/log/datomic/output.log 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