homebrew-core/Formula/fbi-servefiles.rb
2018-11-07 12:31:59 +01:00

57 lines
1.5 KiB
Ruby

class FbiServefiles < Formula
include Language::Python::Virtualenv
desc "Serve local files to Nintendo 3DS via FBI remote installer"
homepage "https://github.com/Steveice10/FBI"
url "https://github.com/Steveice10/FBI/archive/2.5.3.tar.gz"
sha256 "88ab87c31e9fc70c5ef31fb2217b43e638447b0fd1e26d5652cc554630bce264"
bottle do
cellar :any_skip_relocation
sha256 "778ec157541829ec42f374cadd9a5f0849d73b78ee07b1c7d496b3a9639e8648" => :mojave
sha256 "9de12962d6f6af9047184f028147d0fac61f05d33e6c6b08e65cf8ef7ba1165b" => :high_sierra
sha256 "47d7eadf048df60403d45fba40235ac9d91fb338c6a4a0f1da48094cdbadd3c8" => :sierra
end
depends_on "python"
def install
venv = virtualenv_create(libexec)
venv.pip_install_and_link buildpath/"servefiles"
end
test do
require "socket"
def test_socket
server = TCPServer.new(5000)
client = server.accept
client.puts "\n"
client_response = client.gets
client.close
server.close
client_response
end
begin
pid = fork do
system "#{bin}/sendurls.py", "127.0.0.1", "https://github.com"
end
assert_match "https://github.com", test_socket
ensure
Process.kill("TERM", pid)
Process.wait(pid)
end
begin
touch "test.cia"
pid = fork do
system "#{bin}/servefiles.py", "127.0.0.1", "test.cia", "127.0.0.1", "8080"
end
assert_match "127.0.0.1:8080/test.cia", test_socket
ensure
Process.kill("TERM", pid)
Process.wait(pid)
end
end
end