homebrew-core/Formula/webtorrent-cli.rb
2019-07-06 12:45:13 +02:00

48 lines
1.6 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-2.0.1.tgz"
sha256 "206632d7cbd2bca418ebc48d2f67de1083f2695d3ad9d0814ef248c621e7d428"
bottle do
sha256 "c37e3e88c7457fd0d1c85bf9c86eb539682d5425a109c0aa3aaf0ae59ff95859" => :mojave
sha256 "d768daf4c807cbc12ba602abcd3aae3ae94dc31db7f432d172c32d989e747ecc" => :high_sierra
sha256 "95796c057d54a799e69daa370465ff78c5e22ead40532b0aa91427007ef776f3" => :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