83 lines
2.6 KiB
Ruby
83 lines
2.6 KiB
Ruby
require "language/perl"
|
|
|
|
class Asciiquarium < Formula
|
|
include Language::Perl::Shebang
|
|
|
|
desc "Aquarium animation in ASCII art"
|
|
homepage "https://robobunny.com/projects/asciiquarium/html/"
|
|
url "https://robobunny.com/projects/asciiquarium/asciiquarium_1.1.tar.gz"
|
|
sha256 "1b08c6613525e75e87546f4e8984ab3b33f1e922080268c749f1777d56c9d361"
|
|
license "GPL-2.0-or-later"
|
|
revision 2
|
|
|
|
livecheck do
|
|
url "https://robobunny.com/projects/asciiquarium/"
|
|
regex(/href=.*?asciiquarium[._-]v?(\d+(?:\.\d+)+)\.t/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any, big_sur: "b265b239e7c9d417614d16e8df9d000b4b5a74419fa3b9c951f89e38e2d6f2c5"
|
|
sha256 cellar: :any, catalina: "549e7df42d697e47ff38029b4e0d3df4404046ba52296e713b47d02aab0babe7"
|
|
sha256 cellar: :any, mojave: "75d26ee7c7db2b3f8a66216224a13405288fa436123c5c80e53b2f9a9bcfdb3b"
|
|
end
|
|
|
|
depends_on "ncurses"
|
|
depends_on "perl"
|
|
|
|
resource "Curses" do
|
|
url "https://cpan.metacpan.org/authors/id/G/GI/GIRAFFED/Curses-1.37.tar.gz"
|
|
sha256 "74707ae3ad19b35bbefda2b1d6bd31f57b40cdac8ab872171c8714c88954db20"
|
|
end
|
|
|
|
resource "Term::Animation" do
|
|
url "https://cpan.metacpan.org/authors/id/K/KB/KBAUCOM/Term-Animation-2.6.tar.gz"
|
|
sha256 "7d5c3c2d4f9b657a8b1dce7f5e2cbbe02ada2e97c72f3a0304bf3c99d084b045"
|
|
end
|
|
|
|
def install
|
|
ENV.prepend_create_path "PERL5LIB", libexec/"lib/perl5"
|
|
|
|
resources.each do |r|
|
|
r.stage do
|
|
system "perl", "Makefile.PL", "INSTALL_BASE=#{libexec}"
|
|
system "make"
|
|
system "make", "install"
|
|
end
|
|
end
|
|
|
|
# Disable dynamic selection of perl which may cause segfault when an
|
|
# incompatible perl is picked up.
|
|
# https://github.com/Homebrew/homebrew-core/issues/4936
|
|
rewrite_shebang detected_perl_shebang, "asciiquarium"
|
|
|
|
chmod 0755, "asciiquarium"
|
|
bin.install "asciiquarium"
|
|
bin.env_script_all_files(libexec/"bin", PERL5LIB: ENV["PERL5LIB"])
|
|
end
|
|
|
|
test do
|
|
# This is difficult to test because:
|
|
# - There are no command line switches that make the process exit
|
|
# - The output is a constant stream of terminal control codes
|
|
# - Testing only if the binary exists can still result in failure
|
|
|
|
# The test process is as follows:
|
|
# - Spawn the process capturing stdout and the pid
|
|
# - Kill the process after there is some output
|
|
# - Ensure the start of the output matches what is expected
|
|
|
|
require "pty"
|
|
ENV["TERM"] = "xterm"
|
|
PTY.spawn(bin/"asciiquarium") do |stdout, stdin, _pid|
|
|
sleep 1
|
|
stdin.write "q"
|
|
output = begin
|
|
stdout.gets
|
|
rescue Errno::EIO
|
|
nil
|
|
end
|
|
assert_match "\e[?10", output[0..4]
|
|
end
|
|
end
|
|
end
|