55 lines
1.9 KiB
Ruby
55 lines
1.9 KiB
Ruby
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-3.0.7.tgz"
|
|
sha256 "7c6da2d8c800b921af458c94d606dad53d01cdf013fc364bb041a713e886af92"
|
|
license "MIT"
|
|
|
|
bottle do
|
|
sha256 "524dc3212204b210358f2c6798820b17f2634919d60335db7a78a9172d64bac2" => :catalina
|
|
sha256 "75671e025faab37bf9d90fd195b1c6532a3cb0c47c9e01b2e448b8c4d5429cee" => :mojave
|
|
sha256 "7dd6916db1c79502146e5664ce1c47674259c3cdca06bbbe4e579a332e368c29" => :high_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
|
|
|
|
expected_output_raw = <<~EOS
|
|
{
|
|
"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
|
|
expected_json = JSON.parse(expected_output_raw)
|
|
actual_output_raw = shell_output("#{bin}/webtorrent info '#{magnet_uri}'")
|
|
actual_json = JSON.parse(actual_output_raw)
|
|
assert_equal expected_json["tr"].to_set, actual_json["tr"].to_set
|
|
assert_equal expected_json["announce"].to_set, actual_json["announce"].to_set
|
|
end
|
|
end
|