homebrew-core/Formula/cloc.rb
2018-02-10 18:20:00 +01:00

60 lines
2.2 KiB
Ruby

class Cloc < Formula
desc "Statistics utility to count lines of code"
homepage "https://github.com/AlDanial/cloc/"
url "https://github.com/AlDanial/cloc/releases/download/v1.76/cloc-1.76.tar.gz"
sha256 "d43e812b417ec718219fb561ed8f50f2eaac9bf365fd5dfdf127ebc8ffa65917"
head "https://github.com/AlDanial/cloc.git"
bottle do
cellar :any_skip_relocation
sha256 "0123cefae7e75bbb3b64b718b4f984bf6aa1da9efb28fc86f3b2a0687d5d8f5f" => :high_sierra
sha256 "2d16fe94a6a046f2cb9c889e65c396c4cf41bcd9e2d161ddb6cd94892d669d88" => :sierra
sha256 "8c6d4515481aa1738f65332757d7f90ec57103893835460d8c1d0758b261b58e" => :el_capitan
end
resource "Regexp::Common" do
url "https://cpan.metacpan.org/authors/id/A/AB/ABIGAIL/Regexp-Common-2017060201.tar.gz"
sha256 "ee07853aee06f310e040b6bf1a0199a18d81896d3219b9b35c9630d0eb69089b"
end
resource "Algorithm::Diff" do
url "https://cpan.metacpan.org/authors/id/T/TY/TYEMQ/Algorithm-Diff-1.1903.tar.gz"
sha256 "30e84ac4b31d40b66293f7b1221331c5a50561a39d580d85004d9c1fff991751"
end
resource "Parallel::ForkManager" do
url "https://cpan.metacpan.org/authors/id/Y/YA/YANICK/Parallel-ForkManager-1.19.tar.gz"
sha256 "f1de2e9875eeb77d65f80338905dedd522f3913822502982f805aa71cde5a472"
end
def install
ENV.prepend_create_path "PERL5LIB", libexec/"lib/perl5"
# These are shipped as standard with OS X/macOS' default Perl, but
# because upstream has chosen to use "#!/usr/bin/env perl" cloc will
# use whichever Perl is in the PATH, which isn't guaranteed to include
# these modules. Vendor them to be safe.
resources.each do |r|
r.stage do
system "perl", "Makefile.PL", "INSTALL_BASE=#{libexec}"
system "make", "install"
end
end
system "make", "-C", "Unix", "prefix=#{libexec}", "install"
bin.install libexec/"bin/cloc"
bin.env_script_all_files(libexec/"bin", :PERL5LIB => ENV["PERL5LIB"])
man1.install libexec/"share/man/man1/cloc.1"
end
test do
(testpath/"test.c").write <<~EOS
#include <stdio.h>
int main(void) {
return 0;
}
EOS
assert_match "1,C,0,0,4", shell_output("#{bin}/cloc --csv .")
end
end