require "language/node" class WebtorrentCli < Formula desc "Command-line streaming torrent client" homepage "https://webtorrent.io/" url "https://registry.npmjs.org/webtorrent-cli/-/webtorrent-cli-2.0.0.tgz" sha256 "d0c919816e559dbbcb0005128778d6ed200ecf399e78a170bbf8ad3f376336f0" bottle do sha256 "84f8a548ba1770f3e7535efcde3b9016c522f4f9827f34d0814c2ed7239317db" => :mojave sha256 "bf18e0b5f1bd4731665f61704a7c3efa19758165289cf67ea39be7ded32a306c" => :high_sierra sha256 "7ab2e3c2bae5ce609ee8e4c1dcce18286fef13c2cce22068319c894d17d538a6" => :sierra end depends_on "node" def install system "npm", "install", *Language::Node.std_npm_install_args(libexec) bin.install_symlink Dir["#{libexec}/bin/*"] end test do magnet_uri = <<~EOS.gsub(/\s+/, "").strip magnet:?xt=urn:btih:9eae210fe47a073f991c83561e75d439887be3f3 &dn=archlinux-2017.02.01-x86_64.iso &tr=udp://tracker.archlinux.org:6969 &tr=https://tracker.archlinux.org:443/announce EOS assert_equal <<~EOS.chomp, shell_output("#{bin}/webtorrent info '#{magnet_uri}'") { "xt": "urn:btih:9eae210fe47a073f991c83561e75d439887be3f3", "dn": "archlinux-2017.02.01-x86_64.iso", "tr": [ "https://tracker.archlinux.org:443/announce", "udp://tracker.archlinux.org:6969" ], "infoHash": "9eae210fe47a073f991c83561e75d439887be3f3", "name": "archlinux-2017.02.01-x86_64.iso", "announce": [ "https://tracker.archlinux.org:443/announce", "udp://tracker.archlinux.org:6969" ], "urlList": [] } EOS end end