|
| 1 | +class Yaml2json < Formula |
| 2 | + desc "Command-line tool convert from YAML to JSON" |
| 3 | + homepage "https://github.com/bronze1man/yaml2json" |
| 4 | + url "https://github.com/bronze1man/yaml2json/archive/refs/tags/v1.3.5.tar.gz" |
| 5 | + sha256 "efde12ca8b3ab7df3d3eaef35ecfb6e0d54baed33c8d553e7fd611a79c4cee04" |
| 6 | + license "MIT" |
| 7 | + head "https://github.com/bronze1man/yaml2json.git", branch: "master" |
| 8 | + |
| 9 | + bottle do |
| 10 | + sha256 cellar: :any_skip_relocation, arm64_sequoia: "81fdf8b90dfbef0a48912f42db8742d4ee5542d87a3f709504821ba7c4aae7f4" |
| 11 | + sha256 cellar: :any_skip_relocation, arm64_sonoma: "81fdf8b90dfbef0a48912f42db8742d4ee5542d87a3f709504821ba7c4aae7f4" |
| 12 | + sha256 cellar: :any_skip_relocation, arm64_ventura: "81fdf8b90dfbef0a48912f42db8742d4ee5542d87a3f709504821ba7c4aae7f4" |
| 13 | + sha256 cellar: :any_skip_relocation, sonoma: "3d2dd72115aaa4fc3e4cc60dc285c2d76f58283ea90241687ff3bd55fafdbe9d" |
| 14 | + sha256 cellar: :any_skip_relocation, ventura: "3d2dd72115aaa4fc3e4cc60dc285c2d76f58283ea90241687ff3bd55fafdbe9d" |
| 15 | + sha256 cellar: :any_skip_relocation, x86_64_linux: "4d1ad585751d061cdf59a0b4722b31fb48c34f92159426cb2e74d313db63d0b1" |
| 16 | + end |
| 17 | + |
| 18 | + depends_on "go" => :build |
| 19 | + |
| 20 | + def install |
| 21 | + system "go", "build", *std_go_args(ldflags: "-s -w") |
| 22 | + end |
| 23 | + |
| 24 | + test do |
| 25 | + assert_match version.to_s, shell_output("#{bin}/yaml2json --version 2>&1", 1) |
| 26 | + |
| 27 | + (testpath/"test.yaml").write <<~YAML |
| 28 | + firstname: John |
| 29 | + lastname: Doe |
| 30 | + age: 25 |
| 31 | +
|
| 32 | + items: |
| 33 | + - item: Desk |
| 34 | + color: black |
| 35 | +
|
| 36 | + - item: Chair |
| 37 | + color: brown |
| 38 | + YAML |
| 39 | + |
| 40 | + (testpath/"expected.json").write <<~JSON |
| 41 | + { |
| 42 | + "age": 25, |
| 43 | + "firstname": "John", |
| 44 | + "lastname": "Doe", |
| 45 | + "items": [ |
| 46 | + { |
| 47 | + "item": "Desk", |
| 48 | + "color": "black" |
| 49 | + }, |
| 50 | + { |
| 51 | + "item": "Chair", |
| 52 | + "color": "brown" |
| 53 | + } |
| 54 | + ] |
| 55 | + } |
| 56 | + JSON |
| 57 | + |
| 58 | + assert_equal JSON.parse((testpath/"expected.json").read), |
| 59 | + JSON.parse(shell_output("#{bin}/yaml2json < #{testpath}/test.yaml")) |
| 60 | + end |
| 61 | +end |
0 commit comments