Skip to content

Commit 48e420f

Browse files
botantonychenrui333
andcommitted
hjson 4.4.0 (new formula)
Signed-off-by: botantony <[email protected]> Co-authored-by: Rui Chen <[email protected]>
1 parent d825796 commit 48e420f

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

Formula/h/hjson.rb

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
class Hjson < Formula
2+
desc "Convert JSON to HJSON and vice versa"
3+
homepage "https://hjson.github.io/"
4+
url "https://github.com/hjson/hjson-go/archive/refs/tags/v4.4.0.tar.gz"
5+
sha256 "ba09dd33d655d99578f78722035e136449fcc6eaf1dc1b12eef1f0bb858749d4"
6+
license "MIT"
7+
head "https://github.com/hjson/hjson-go.git", branch: "master"
8+
9+
depends_on "go" => :build
10+
11+
def install
12+
system "go", "build", *std_go_args(ldflags: "-s -w -X main.Version=#{version}"), "./hjson-cli"
13+
end
14+
15+
test do
16+
assert_match version.to_s, shell_output("#{bin}/hjson -v")
17+
18+
(testpath/"test.hjson").write <<~HJSON
19+
{
20+
# comment
21+
// a comment too
22+
/*
23+
* multiline comments
24+
*/
25+
rate: 1000
26+
key: value
27+
text: look ma, no quotes!
28+
commas:
29+
{
30+
one: 1
31+
two: 2
32+
}
33+
trailing:
34+
{
35+
one: 1
36+
two: 2
37+
}
38+
haiku:
39+
'''
40+
JSON I love you.
41+
But you strangle my expression.
42+
This is so much better.
43+
'''
44+
favNumbers:
45+
[
46+
1
47+
2
48+
3
49+
6
50+
42
51+
]
52+
}
53+
HJSON
54+
55+
(testpath/"expected.json").write <<~JSON
56+
{
57+
commas:
58+
{
59+
one: 1
60+
two: 2
61+
}
62+
favNumbers:
63+
[
64+
1
65+
2
66+
3
67+
6
68+
42
69+
]
70+
haiku:
71+
'''
72+
JSON I love you.
73+
But you strangle my expression.
74+
This is so much better.
75+
'''
76+
key: value
77+
rate: 1000
78+
text: look ma, no quotes!
79+
trailing:
80+
{
81+
one: 1
82+
two: 2
83+
}
84+
}
85+
JSON
86+
87+
assert_equal (testpath/"expected.json").read, shell_output("#{bin}/hjson #{testpath}/test.hjson")
88+
end
89+
end

0 commit comments

Comments
 (0)