homebrew-core/Formula/perltidy.rb

47 lines
1.7 KiB
Ruby

class Perltidy < Formula
desc "Indents and reformats Perl scripts to make them easier to read"
homepage "https://perltidy.sourceforge.io/"
url "https://downloads.sourceforge.net/project/perltidy/20200822/Perl-Tidy-20200822.tar.gz"
sha256 "757ac07bec59707845995aaafbb44b664120f57850ce932bc31f2d95e0c5df36"
license "GPL-2.0-or-later"
livecheck do
url :stable
regex(%r{url=.*?/Perl-Tidy[._-]v?(\d+)\.t}i)
end
bottle do
cellar :any_skip_relocation
sha256 "83b5f90746f0da498b17d0fb86ac46e56699431e0e901477a7dc6a3f07e6d43c" => :catalina
sha256 "4f2b608d8526fbce59ecfea6852183e51eec83a30ac68d7b56b2605cfc243146" => :mojave
sha256 "bc835bc37de6b359948b3e2d65bbb2e36c1758e5145860b928d519d591ae4b25" => :high_sierra
end
def install
ENV.prepend_create_path "PERL5LIB", libexec/"lib/perl5"
system "perl", "Makefile.PL", "INSTALL_BASE=#{libexec}",
"INSTALLSITESCRIPT=#{bin}",
"INSTALLSITEMAN1DIR=#{man1}",
"INSTALLSITEMAN3DIR=#{man3}"
system "make"
system "make", "install"
bin.env_script_all_files(libexec/"bin", PERL5LIB: ENV["PERL5LIB"])
end
test do
(testpath/"testfile.pl").write <<~EOS
print "Help Desk -- What Editor do you use?";
chomp($editor = <STDIN>);
if ($editor =~ /emacs/i) {
print "Why aren't you using vi?\n";
} elsif ($editor =~ /vi/i) {
print "Why aren't you using emacs?\n";
} else {
print "I think that's the problem\n";
}
EOS
system bin/"perltidy", testpath/"testfile.pl"
assert_predicate testpath/"testfile.pl.tdy", :exist?
end
end