class Webdis < Formula desc "Redis HTTP interface with JSON output" homepage "https://webd.is/" url "https://github.com/nicolasff/webdis/archive/0.1.7.tar.gz" sha256 "932e8b2d75ea6093759c4f9a228c34de664a1d41c2ef3aaa57fa61cdc38024a2" bottle do cellar :any sha256 "1a624e8fc6cefbb09e39fa7288354155fb31bab4ab8d820158838aab115b2fd6" => :mojave sha256 "e8a30bb8af33fbf2f752e52bee6afaff0856fe8c5270fed65267b69e4d7dd954" => :high_sierra sha256 "164d648013e27d26972d8bdc39fff4a884533aef2a3026c330ecf1b536ff76ea" => :sierra end depends_on "libevent" def install system "make" bin.install "webdis" inreplace "webdis.prod.json" do |s| s.gsub! "/var/log/webdis.log", "#{var}/log/webdis.log" s.gsub! /daemonize":\s*true/, "daemonize\":\tfalse" end etc.install "webdis.json", "webdis.prod.json" end def post_install (var/"log").mkpath end plist_options :manual => "webdis #{HOMEBREW_PREFIX}/etc/webdis.json" def plist; <<~EOS Label #{plist_name} ProgramArguments #{opt_bin}/webdis #{etc}/webdis.prod.json RunAtLoad KeepAlive SuccessfulExit WorkingDirectory #{var} EOS end test do begin server = fork do exec "#{bin}/webdis", "#{etc}/webdis.json" end sleep 0.5 # Test that the response is from webdis assert_match(/Server: Webdis/, shell_output("curl --silent -XGET -I http://localhost:7379/PING")) ensure Process.kill "TERM", server Process.wait server end end end