hocon 1.1.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/CHANGELOG.md +11 -0
- data/HISTORY.md +2016 -0
- data/README.md +123 -0
- data/bin/hocon +5 -0
- data/lib/hocon/cli.rb +225 -0
- data/lib/hocon/config_render_options.rb +3 -2
- data/lib/hocon/impl/abstract_config_value.rb +7 -10
- data/lib/hocon/impl/config_delayed_merge.rb +1 -1
- data/lib/hocon/impl/config_node_object.rb +1 -2
- data/lib/hocon/impl/config_node_root.rb +1 -1
- data/lib/hocon/impl/simple_config_document.rb +1 -1
- data/lib/hocon/version.rb +5 -0
- data/spec/fixtures/parse_render/example1/output.conf +3 -3
- data/spec/test_utils.rb +2 -1
- data/spec/unit/cli/cli_spec.rb +157 -0
- data/spec/unit/typesafe/config/config_document_spec.rb +41 -41
- data/spec/unit/typesafe/config/config_node_spec.rb +12 -12
- data/spec/unit/typesafe/config/config_value_spec.rb +24 -0
- metadata +18 -12
@@ -31,12 +31,12 @@ describe Hocon::Parser::ConfigNode do
|
|
31
31
|
shared_examples_for "field node test" do
|
32
32
|
it "should properly replace the value of a field node" do
|
33
33
|
key_val_node = TestUtils.node_key_value_pair(key, value)
|
34
|
-
expect(key_val_node.render).to eq("#{key.render}
|
34
|
+
expect(key_val_node.render).to eq("#{key.render}: #{value.render}")
|
35
35
|
expect(key_val_node.path.render).to eq(key.render)
|
36
36
|
expect(key_val_node.value.render).to eq(value.render)
|
37
37
|
|
38
38
|
new_key_val_node = key_val_node.replace_value(new_value)
|
39
|
-
expect(new_key_val_node.render).to eq("#{key.render}
|
39
|
+
expect(new_key_val_node.render).to eq("#{key.render}: #{new_value.render}")
|
40
40
|
expect(new_key_val_node.value.render).to eq(new_value.render)
|
41
41
|
end
|
42
42
|
end
|
@@ -48,8 +48,8 @@ describe Hocon::Parser::ConfigNode do
|
|
48
48
|
TestUtils.node_close_brace]
|
49
49
|
complex_node = TestUtils.config_node_object(complex_node_children)
|
50
50
|
new_node = complex_node.set_value_on_path(key, new_value)
|
51
|
-
orig_text = "{#{key}
|
52
|
-
final_text = "{#{key}
|
51
|
+
orig_text = "{#{key}: #{value.render}}"
|
52
|
+
final_text = "{#{key}: #{new_value.render}}"
|
53
53
|
|
54
54
|
expect(complex_node.render).to eq(orig_text)
|
55
55
|
expect(new_node.render).to eq(final_text)
|
@@ -64,7 +64,7 @@ describe Hocon::Parser::ConfigNode do
|
|
64
64
|
key_val_pair_3 = TestUtils.node_key_value_pair(key, value3)
|
65
65
|
complex_node = TestUtils.config_node_object([key_val_pair_1, key_val_pair_2, key_val_pair_3])
|
66
66
|
orig_text = "#{key_val_pair_1.render}#{key_val_pair_2.render}#{key_val_pair_3.render}"
|
67
|
-
final_text = "#{key.render}
|
67
|
+
final_text = "#{key.render}: 15"
|
68
68
|
|
69
69
|
expect(complex_node.render).to eq(orig_text)
|
70
70
|
expect(complex_node.set_value_on_path("foo", TestUtils.node_int(15)).render).to eq(final_text)
|
@@ -74,9 +74,9 @@ describe Hocon::Parser::ConfigNode do
|
|
74
74
|
shared_examples_for "non existent path test" do
|
75
75
|
it "should properly add a key/value pair if the key does not exist in the object" do
|
76
76
|
node = TestUtils.config_node_object([TestUtils.node_key_value_pair(TestUtils.config_node_key("bar"), TestUtils.node_int(15))])
|
77
|
-
expect(node.render).to eq('bar
|
77
|
+
expect(node.render).to eq('bar: 15')
|
78
78
|
new_node = node.set_value_on_path('foo', value)
|
79
|
-
final_text = "bar
|
79
|
+
final_text = "bar: 15, foo: #{value.render}"
|
80
80
|
expect(new_node.render).to eq(final_text)
|
81
81
|
end
|
82
82
|
end
|
@@ -508,8 +508,8 @@ describe Hocon::Parser::ConfigNode do
|
|
508
508
|
# Replacement of nested nodes
|
509
509
|
#################################
|
510
510
|
context "replace nested nodes" do
|
511
|
-
orig_text = "foo
|
512
|
-
"def
|
511
|
+
orig_text = "foo: bar\nbaz: {\n\t\"abc.def\": 123\n\t//This is a comment about the below setting\n\n\tabc: {\n\t\t" +
|
512
|
+
"def: \"this is a string\"\n\t\tghi: ${\"a.b\"}\n\t}\n}\nbaz.abc.ghi: 52\nbaz.abc.ghi: 53\n}"
|
513
513
|
lowest_level_map = TestUtils.config_node_object([TestUtils.node_open_brace, TestUtils.node_line(6), TestUtils.node_whitespace("\t\t"),
|
514
514
|
TestUtils.node_key_value_pair(TestUtils.config_node_key("def"), TestUtils.config_node_simple_value(TestUtils.token_string("this is a string"))),
|
515
515
|
TestUtils.node_line(7), TestUtils.node_whitespace("\t\t"),
|
@@ -531,8 +531,8 @@ describe Hocon::Parser::ConfigNode do
|
|
531
531
|
end
|
532
532
|
|
533
533
|
it "should properly replae values in the original node" do
|
534
|
-
final_text = "foo
|
535
|
-
"def
|
534
|
+
final_text = "foo: bar\nbaz: {\n\t\"abc.def\": true\n\t//This is a comment about the below setting\n\n\tabc: {\n\t\t" +
|
535
|
+
"def: false\n\t\t\n\t\t\"this.does.not.exist@@@+$#\": {\n\t\t end: doesnotexist\n\t\t}\n\t}\n}\n\nbaz.abc.ghi: randomunquotedString\n}"
|
536
536
|
|
537
537
|
# Paths with quotes in the name are treated as a single Path, rather than multiple sub-paths
|
538
538
|
new_node = orig_node.set_value_on_path('baz."abc.def"', TestUtils.config_node_simple_value(TestUtils.token_true))
|
@@ -549,4 +549,4 @@ describe Hocon::Parser::ConfigNode do
|
|
549
549
|
end
|
550
550
|
end
|
551
551
|
|
552
|
-
end
|
552
|
+
end
|
@@ -932,4 +932,28 @@ describe "#render" do
|
|
932
932
|
|
933
933
|
expect(rendered).to eq('{"0":"a","1":"b","2":"c","3":"d","10":"e","20":"f","30":"g"}')
|
934
934
|
end
|
935
|
+
|
936
|
+
context "RenderOptions.key_value_separator" do
|
937
|
+
specify "should use colons when set to :colon" do
|
938
|
+
conf = Hocon::ConfigValueFactory.from_any_ref({foo: {bar: 'baz'}})
|
939
|
+
expected = "foo: {\n bar: baz\n}\n"
|
940
|
+
render_options = ConfigRenderOptions.defaults
|
941
|
+
render_options.json = false
|
942
|
+
render_options.key_value_separator = :colon
|
943
|
+
render_options.origin_comments = false
|
944
|
+
|
945
|
+
expect(conf.render(render_options)).to eq(expected)
|
946
|
+
end
|
947
|
+
|
948
|
+
specify "should use equals signs when set to :equals" do
|
949
|
+
conf = Hocon::ConfigValueFactory.from_any_ref({foo: {bar: 'baz'}})
|
950
|
+
expected = "foo={\n bar=baz\n}\n"
|
951
|
+
render_options = ConfigRenderOptions.defaults
|
952
|
+
render_options.json = false
|
953
|
+
render_options.origin_comments = false
|
954
|
+
render_options.key_value_separator = :equals
|
955
|
+
|
956
|
+
expect(conf.render(render_options)).to eq(expected)
|
957
|
+
end
|
958
|
+
end
|
935
959
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hocon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Price
|
@@ -13,47 +13,51 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2016-10-
|
16
|
+
date: 2016-10-27 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: bundler
|
20
20
|
requirement: !ruby/object:Gem::Requirement
|
21
21
|
requirements:
|
22
|
-
- -
|
22
|
+
- - ~>
|
23
23
|
- !ruby/object:Gem::Version
|
24
24
|
version: '1.5'
|
25
25
|
type: :development
|
26
26
|
prerelease: false
|
27
27
|
version_requirements: !ruby/object:Gem::Requirement
|
28
28
|
requirements:
|
29
|
-
- -
|
29
|
+
- - ~>
|
30
30
|
- !ruby/object:Gem::Version
|
31
31
|
version: '1.5'
|
32
32
|
- !ruby/object:Gem::Dependency
|
33
33
|
name: rspec
|
34
34
|
requirement: !ruby/object:Gem::Requirement
|
35
35
|
requirements:
|
36
|
-
- -
|
36
|
+
- - ~>
|
37
37
|
- !ruby/object:Gem::Version
|
38
38
|
version: '2.14'
|
39
39
|
type: :development
|
40
40
|
prerelease: false
|
41
41
|
version_requirements: !ruby/object:Gem::Requirement
|
42
42
|
requirements:
|
43
|
-
- -
|
43
|
+
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '2.14'
|
46
|
-
description:
|
47
|
-
library to Ruby
|
46
|
+
description: == A port of the Java {Typesafe Config}[https://github.com/typesafehub/config]
|
47
|
+
library to Ruby
|
48
48
|
email: chris@puppetlabs.com
|
49
|
-
executables:
|
49
|
+
executables:
|
50
|
+
- hocon
|
50
51
|
extensions: []
|
51
52
|
extra_rdoc_files: []
|
52
53
|
files:
|
53
54
|
- CHANGELOG.md
|
55
|
+
- HISTORY.md
|
54
56
|
- LICENSE
|
55
57
|
- README.md
|
58
|
+
- bin/hocon
|
56
59
|
- lib/hocon.rb
|
60
|
+
- lib/hocon/cli.rb
|
57
61
|
- lib/hocon/config.rb
|
58
62
|
- lib/hocon/config_error.rb
|
59
63
|
- lib/hocon/config_factory.rb
|
@@ -139,6 +143,7 @@ files:
|
|
139
143
|
- lib/hocon/parser/config_document.rb
|
140
144
|
- lib/hocon/parser/config_document_factory.rb
|
141
145
|
- lib/hocon/parser/config_node.rb
|
146
|
+
- lib/hocon/version.rb
|
142
147
|
- spec/fixtures/hocon/by_extension/cat.conf
|
143
148
|
- spec/fixtures/hocon/by_extension/cat.test
|
144
149
|
- spec/fixtures/hocon/by_extension/cat.test-json
|
@@ -168,6 +173,7 @@ files:
|
|
168
173
|
- spec/fixtures/test_utils/resources/ᚠᛇᚻ.conf
|
169
174
|
- spec/spec_helper.rb
|
170
175
|
- spec/test_utils.rb
|
176
|
+
- spec/unit/cli/cli_spec.rb
|
171
177
|
- spec/unit/hocon/README.md
|
172
178
|
- spec/unit/hocon/hocon_spec.rb
|
173
179
|
- spec/unit/typesafe/config/README.md
|
@@ -194,17 +200,17 @@ require_paths:
|
|
194
200
|
- lib
|
195
201
|
required_ruby_version: !ruby/object:Gem::Requirement
|
196
202
|
requirements:
|
197
|
-
- -
|
203
|
+
- - ! '>='
|
198
204
|
- !ruby/object:Gem::Version
|
199
205
|
version: 1.9.0
|
200
206
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
201
207
|
requirements:
|
202
|
-
- -
|
208
|
+
- - ! '>='
|
203
209
|
- !ruby/object:Gem::Version
|
204
210
|
version: '0'
|
205
211
|
requirements: []
|
206
212
|
rubyforge_project:
|
207
|
-
rubygems_version: 2.
|
213
|
+
rubygems_version: 2.4.5
|
208
214
|
signing_key:
|
209
215
|
specification_version: 4
|
210
216
|
summary: HOCON Config Library
|