diff --git a/Formula/range2cidr.rb b/Formula/range2cidr.rb new file mode 100644 index 000000000000..20f333d4d060 --- /dev/null +++ b/Formula/range2cidr.rb @@ -0,0 +1,20 @@ +class Range2cidr < Formula + desc "Converts IP ranges to CIDRs" + homepage "https://ipinfo.io" + url "https://github.com/ipinfo/cli/archive/range2cidr-1.0.0.tar.gz" + sha256 "caf6627b361ce690a884ccbb98c229d07dcf73e453af625638b7508113e1b0df" + license "Apache-2.0" + + depends_on "go" => :build + + def install + system "go", "build", *std_go_args, "./range2cidr" + end + + test do + assert_equal version.to_s, shell_output("#{bin}/range2cidr --version").chomp + assert_equal "1.1.1.0/30", shell_output("#{bin}/range2cidr 1.1.1.0-1.1.1.3").chomp + assert_equal "0.0.0.0/0", shell_output("#{bin}/range2cidr 0.0.0.0-255.255.255.255").chomp + assert_equal "1.1.1.0/31\n1.1.1.2/32", shell_output("#{bin}/range2cidr 1.1.1.0-1.1.1.2").chomp + end +end