homebrew-core/Formula/webdis.rb
2018-08-24 15:52:05 +02:00

74 lines
2.1 KiB
Ruby

class Webdis < Formula
desc "Redis HTTP interface with JSON output"
homepage "https://webd.is/"
url "https://github.com/nicolasff/webdis/archive/0.1.4.tar.gz"
sha256 "2e384eae48cfc2e4503e3311c61d4790e5d3b3ab5cf82ec554c0bef5d84c6807"
bottle do
cellar :any
sha256 "212a9557b0dc359e000c970e6d7810f5511fc9da3e207adcec92e80c349bed02" => :mojave
sha256 "6d657c81a720f4891f8d04e3f7d575cfe1df10c70a30047ce06de33ff8fd57fc" => :high_sierra
sha256 "3d8b342f5638b134799bd307af578c0d95a28ccd3ecb8060749a6c026140510e" => :sierra
sha256 "2b8ba2575cd03917af7362218324fbefa38336306565875565f40daa20b0f050" => :el_capitan
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
<?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>ProgramArguments</key>
<array>
<string>#{opt_bin}/webdis</string>
<string>#{etc}/webdis.prod.json</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
<key>WorkingDirectory</key>
<string>#{var}</string>
</dict>
</plist>
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