|
| 1 | +class Webdav < Formula |
| 2 | + desc "Simple and standalone WebDAV server" |
| 3 | + homepage "https://github.com/hacdias/webdav" |
| 4 | + url "https://github.com/hacdias/webdav/archive/refs/tags/v5.8.0.tar.gz" |
| 5 | + sha256 "fc9e5272c821f5a4ca98321195469a87a9ba8a8c696c0f4d3008407ee8150039" |
| 6 | + license "MIT" |
| 7 | + head "https://github.com/hacdias/webdav.git", branch: "main" |
| 8 | + |
| 9 | + bottle do |
| 10 | + sha256 cellar: :any_skip_relocation, arm64_sequoia: "baf72b71abacfc241a374cb784db63779bed55040b4dec593d8fe4c35177331b" |
| 11 | + sha256 cellar: :any_skip_relocation, arm64_sonoma: "baf72b71abacfc241a374cb784db63779bed55040b4dec593d8fe4c35177331b" |
| 12 | + sha256 cellar: :any_skip_relocation, arm64_ventura: "baf72b71abacfc241a374cb784db63779bed55040b4dec593d8fe4c35177331b" |
| 13 | + sha256 cellar: :any_skip_relocation, sonoma: "061895843ab8e5c0174f3456a265eeda0cdaf3a94509a6db1c5d86848910d6db" |
| 14 | + sha256 cellar: :any_skip_relocation, ventura: "061895843ab8e5c0174f3456a265eeda0cdaf3a94509a6db1c5d86848910d6db" |
| 15 | + sha256 cellar: :any_skip_relocation, x86_64_linux: "ecf0b783e2adc344c36b94769f905517878de854f8eb4929238dbb1985284ac1" |
| 16 | + end |
| 17 | + |
| 18 | + depends_on "go" => :build |
| 19 | + |
| 20 | + def install |
| 21 | + ldflags = "-s -w -X github.com/hacdias/webdav/v5/cmd.version=#{version}" |
| 22 | + system "go", "build", *std_go_args(ldflags:) |
| 23 | + |
| 24 | + generate_completions_from_executable(bin/"webdav", "completion") |
| 25 | + end |
| 26 | + |
| 27 | + test do |
| 28 | + port = free_port |
| 29 | + (testpath/"config.yaml").write <<~YAML |
| 30 | + address: 127.0.0.1 |
| 31 | + port: #{port} |
| 32 | + directory: #{testpath} |
| 33 | + YAML |
| 34 | + |
| 35 | + (testpath/"hello").write "World!" |
| 36 | + |
| 37 | + begin |
| 38 | + pid = spawn bin/"webdav", "--config", testpath/"config.yaml" |
| 39 | + sleep 2 |
| 40 | + |
| 41 | + assert_match "World!", shell_output("curl -s http://127.0.0.1:#{port}/hello") |
| 42 | + assert_match version.to_s, shell_output("#{bin}/webdav version") |
| 43 | + ensure |
| 44 | + Process.kill("SIGINT", pid) |
| 45 | + Process.wait(pid) |
| 46 | + end |
| 47 | + end |
| 48 | +end |
0 commit comments