|
| 1 | +class RustypasteCli < Formula |
| 2 | + desc "CLI tool for rustypaste" |
| 3 | + homepage "https://blog.orhun.dev/blazingly-fast-file-sharing" |
| 4 | + url "https://github.com/orhun/rustypaste-cli/archive/refs/tags/v0.9.4.tar.gz" |
| 5 | + sha256 "d12b8acb028a92fc6d16347ce3c4b3fa89c86cb902a4a291c116077cc41b1e92" |
| 6 | + license "MIT" |
| 7 | + head "https://github.com/orhun/rustypaste-cli.git", branch: "master" |
| 8 | + |
| 9 | + depends_on "rust" => :build |
| 10 | + depends_on "rustypaste" => :test |
| 11 | + |
| 12 | + def install |
| 13 | + system "cargo", "install", *std_cargo_args |
| 14 | + pkgshare.install "config.toml" |
| 15 | + end |
| 16 | + |
| 17 | + def caveats |
| 18 | + <<~EOS |
| 19 | + An example config is installed to #{opt_pkgshare}/config.toml |
| 20 | + EOS |
| 21 | + end |
| 22 | + |
| 23 | + test do |
| 24 | + # Upload error: `invalid file size (status code: 400)` |
| 25 | + return if OS.linux? && ENV["HOMEBREW_GITHUB_ACTIONS"] |
| 26 | + |
| 27 | + rustypaste = Formula["rustypaste"] |
| 28 | + cp rustypaste.opt_pkgshare/"config.toml", testpath/"config.toml" |
| 29 | + port = free_port |
| 30 | + address = "127.0.0.1:#{port}" |
| 31 | + inreplace testpath/"config.toml", |
| 32 | + 'address = "127.0.0.1:8000"', |
| 33 | + %Q(address = "#{address}") |
| 34 | + |
| 35 | + (testpath/".config/rustypaste/config.toml").write <<~EOS |
| 36 | + [server] |
| 37 | + address = "http://#{address}" |
| 38 | +
|
| 39 | + [paste] |
| 40 | + oneshot = false |
| 41 | + EOS |
| 42 | + |
| 43 | + begin |
| 44 | + server = spawn rustypaste.opt_bin/"rustypaste" |
| 45 | + sleep 1 |
| 46 | + |
| 47 | + file = "awesome.txt" |
| 48 | + text = "some text" |
| 49 | + (testpath/file).write text |
| 50 | + url = shell_output("#{bin}/rpaste #{file}").chomp |
| 51 | + assert_equal text, shell_output("curl #{url}") |
| 52 | + |
| 53 | + text = "Hello World" |
| 54 | + url = pipe_output("#{bin}/rpaste -", text) |
| 55 | + assert_equal text, shell_output("curl #{url}") |
| 56 | + ensure |
| 57 | + Process.kill "TERM", server |
| 58 | + Process.wait server |
| 59 | + end |
| 60 | + end |
| 61 | +end |
0 commit comments