layeredyamlconfig 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,23 @@
1
+ require 'minitest_helper'
2
+ require 'minitest/autorun'
3
+ require 'layeredyamlconfig'
4
+
5
+ class OurConfig < LayeredYAMLConfig
6
+ end
7
+
8
+ class TestErbEmpty < Minitest::Test
9
+ def setup
10
+ OurConfig.clear
11
+ OurConfig.reset
12
+ end
13
+ def test_erb_empty
14
+ OurConfig.templates = true
15
+ assert_raises(RuntimeError) {
16
+ OurConfig.instance 'test/ex17.yaml'
17
+ }
18
+ OurConfig.emptyok = true
19
+ c = OurConfig.instance 'test/ex17.yaml'
20
+ assert_instance_of(OurConfig, c)
21
+ assert_empty c[:a][:b][:e]
22
+ end
23
+ end
@@ -0,0 +1,21 @@
1
+ require 'minitest_helper'
2
+ require 'minitest/autorun'
3
+ require 'layeredyamlconfig'
4
+
5
+ class OurConfig < LayeredYAMLConfig
6
+ end
7
+
8
+ class TestErbHash < Minitest::Test
9
+ def setup
10
+ OurConfig.clear
11
+ OurConfig.reset
12
+ end
13
+ def test_erb_hash_of_hash
14
+ OurConfig.templates = true
15
+ c = OurConfig.instance 'test/ex18.yaml'
16
+ assert_instance_of(OurConfig, c)
17
+ assert_equal '1', c[:b][:one][:a]
18
+ assert_equal '2', c[:b][:two][:b]
19
+ assert_equal '3', c[:b][:three][:c]
20
+ end
21
+ end
@@ -0,0 +1,34 @@
1
+ require 'minitest_helper'
2
+ require 'minitest/autorun'
3
+ require 'layeredyamlconfig'
4
+
5
+ class OurConfig < LayeredYAMLConfig
6
+ end
7
+
8
+ class TestErbMulti < Minitest::Test
9
+ def setup
10
+ OurConfig.clear
11
+ OurConfig.reset
12
+ end
13
+ def test_erb_multi
14
+ OurConfig.templates = true
15
+ assert_raises(RuntimeError) {
16
+ OurConfig.instance 'test/ex11.yaml'
17
+ }
18
+ c = OurConfig.instance 'test/ex11.yaml', 'test/ex12.yaml'
19
+ assert_instance_of(OurConfig, c)
20
+ assert_equal 'gzonk', c[:foo][:bar][:baz]
21
+ end
22
+ def test_erb_multi_recursive
23
+ OurConfig.templates = true
24
+ assert_raises(RuntimeError) {
25
+ OurConfig.instance 'test/ex13.yaml'
26
+ }
27
+ assert_raises(RuntimeError) {
28
+ OurConfig.instance 'test/ex13.yaml', 'test/ex14.yaml'
29
+ }
30
+ c = OurConfig.instance 'test/ex13.yaml', 'test/ex14.yaml', 'test/ex15.yaml'
31
+ assert_instance_of(OurConfig, c)
32
+ assert_equal 'j', c[:a][:b][:c]
33
+ end
34
+ end
@@ -0,0 +1,22 @@
1
+ require 'minitest_helper'
2
+ require 'minitest/autorun'
3
+ require 'pathname'
4
+ require 'layeredyamlconfig'
5
+
6
+ class OurConfig < LayeredYAMLConfig
7
+ end
8
+
9
+ class TestFiles < Minitest::Test
10
+ def setup
11
+ OurConfig.clear
12
+ OurConfig.reset
13
+ end
14
+ def test_files
15
+ c = OurConfig.instance( 'test/ex1.yaml', 'test/ex3.yaml', 'test/ex4.yaml' )
16
+ assert_instance_of(OurConfig, c)
17
+ files = c.files
18
+ assert_equal( 'test/ex1.yaml', files[0] )
19
+ assert_equal( 'test/ex3.yaml', files[1] )
20
+ assert_equal( 'test/ex4.yaml', files[2] )
21
+ end
22
+ end
@@ -0,0 +1,38 @@
1
+ require 'minitest_helper'
2
+ require 'minitest/autorun'
3
+ require 'layeredyamlconfig'
4
+
5
+ class OurConfig < LayeredYAMLConfig
6
+ end
7
+
8
+ class TestInvalidYaml < Minitest::Test
9
+ def setup
10
+ OurConfig.clear
11
+ OurConfig.reset
12
+ end
13
+ def test_badyaml
14
+ assert_raises(ArgumentError) {
15
+ OurConfig.instance( 'test/exbad1.yaml' )
16
+ }
17
+ end
18
+ def test_nothashyaml
19
+ assert_raises(ArgumentError) {
20
+ OurConfig.instance( 'test/exbad2.yaml' )
21
+ }
22
+ end
23
+ def test_missingfile
24
+ cfg = OurConfig.instance( 'test/nonexistent.yaml' )
25
+ assert_instance_of(OurConfig, cfg)
26
+ end
27
+ def test_missingfile_off
28
+ OurConfig.skipmissing = false
29
+ assert_raises(ArgumentError) {
30
+ OurConfig.instance( 'test/nonexistent.yaml' )
31
+ }
32
+ end
33
+ def test_skipbad_on
34
+ OurConfig.skipbad = true
35
+ cfg = OurConfig.instance( 'test/exbad2.yaml' )
36
+ assert_instance_of(OurConfig, cfg)
37
+ end
38
+ end
@@ -0,0 +1,54 @@
1
+ require 'minitest_helper'
2
+ require 'minitest/autorun'
3
+ require 'layeredyamlconfig'
4
+
5
+ class OurConfig1 < LayeredYAMLConfig
6
+ end
7
+
8
+ class OurConfig2 < LayeredYAMLConfig
9
+ end
10
+
11
+ class TestMulti < Minitest::Test
12
+ def setup
13
+ LayeredYAMLConfig.clear_all
14
+ LayeredYAMLConfig.reset_all
15
+ end
16
+ def test_construct_two_from_same_file
17
+ c1 = OurConfig1.instance( 'test/ex1.yaml' )
18
+ c2 = OurConfig2.instance( 'test/ex1.yaml' )
19
+ assert_instance_of(OurConfig1, c1)
20
+ assert_instance_of(OurConfig2, c2)
21
+ assert_equal('bar', c1[:foo])
22
+ assert_equal('bar', c2['foo'])
23
+ assert_equal('bar', c1[:foo])
24
+ assert_equal('bar', c2['foo'])
25
+ end
26
+ def test_construct_two_from_diff_files
27
+ c1 = OurConfig1.instance( 'test/ex1.yaml' )
28
+ c2 = OurConfig2.instance( 'test/ex2.yaml' )
29
+ assert_instance_of(OurConfig1, c1)
30
+ assert_instance_of(OurConfig2, c2)
31
+ assert_equal('bar', c1[:foo])
32
+ assert_equal('baz', c2[:bar])
33
+ assert_equal('bar', c1['foo'])
34
+ assert_equal('baz', c2['bar'])
35
+ refute_equal(c1, c2)
36
+ end
37
+ def test_reconstruct
38
+ c1 = OurConfig1.instance( 'test/ex1.yaml' )
39
+ assert_instance_of(OurConfig1, c1)
40
+ assert_raises(ArgumentError) {
41
+ OurConfig1.instance( 'test/ex2.yaml' )
42
+ }
43
+ end
44
+ def test_override
45
+ c1 = OurConfig1.instance( 'test/ex3.yaml', 'test/ex4.yaml' )
46
+ c2 = OurConfig2.instance( 'test/ex4.yaml', 'test/ex3.yaml' )
47
+ assert_instance_of(OurConfig1, c1)
48
+ assert_instance_of(OurConfig2, c2)
49
+ assert_equal('baz', c1[:foo])
50
+ assert_equal('bar', c2[:foo])
51
+ end
52
+ def test_deep_override
53
+ end
54
+ end
@@ -0,0 +1,18 @@
1
+ require 'minitest_helper'
2
+ require 'minitest/autorun'
3
+ require 'layeredyamlconfig'
4
+
5
+ class OurConfig < LayeredYAMLConfig
6
+ end
7
+
8
+ class TestToHash < Minitest::Test
9
+ def setup
10
+ OurConfig.clear
11
+ OurConfig.reset
12
+ end
13
+ def test_tohash
14
+ c = OurConfig.instance( 'test/ex1.yaml' )
15
+ assert_instance_of(OurConfig, c)
16
+ assert_equal( { 'foo' => 'bar' }, c.to_hash )
17
+ end
18
+ end
metadata ADDED
@@ -0,0 +1,156 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: layeredyamlconfig
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.4.3
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - James FitzGibbon
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-09-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rdoc
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '4.0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '4.0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: hoe
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '3.7'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '3.7'
46
+ description: ! "LayeredYAMLConfig provides a simple config file that supports multiple\nlayers.
47
+ \ Values in the right or uppermost layers override values in lower\nlayers. This
48
+ makes it easy to share configuration without duplication while\nstill allowing what
49
+ needs to be different to vary.\n\nFor example:\n\n program.default.conf\n program.server_foo.conf\n
50
+ \ program.site_bar.conf\n program.conf\n\nOptionally, leaf nodes can be evaluated
51
+ using as ERB templates, feeding the\nconfiguration into itself."
52
+ email:
53
+ - james@nadt.net
54
+ executables: []
55
+ extensions: []
56
+ extra_rdoc_files:
57
+ - History.txt
58
+ - Manifest.txt
59
+ - README.txt
60
+ - LICENSE.txt
61
+ files:
62
+ - History.txt
63
+ - Manifest.txt
64
+ - README.txt
65
+ - LICENSE.txt
66
+ - Rakefile
67
+ - layeredyamlconfig.gemspec
68
+ - lib/layeredyamlconfig.rb
69
+ - lib/layeredyamlconfig/array_traverse.rb
70
+ - lib/layeredyamlconfig/core.rb
71
+ - lib/layeredyamlconfig/hash_traverse.rb
72
+ - lib/layeredyamlconfig/templates.rb
73
+ - test/minitest_helper.rb
74
+ - test/ex1.yaml
75
+ - test/ex2.yaml
76
+ - test/ex3.yaml
77
+ - test/ex4.yaml
78
+ - test/ex5.yaml
79
+ - test/ex6.yaml
80
+ - test/ex7.yaml
81
+ - test/ex8.yaml
82
+ - test/ex9.yaml
83
+ - test/ex10.yaml
84
+ - test/ex11.yaml
85
+ - test/ex12.yaml
86
+ - test/ex13.yaml
87
+ - test/ex14.yaml
88
+ - test/ex15.yaml
89
+ - test/ex16.yaml
90
+ - test/ex17.yaml
91
+ - test/ex18.yaml
92
+ - test/exbad1.yaml
93
+ - test/exbad2.yaml
94
+ - test/test_addlayer.rb
95
+ - test/test_clear.rb
96
+ - test/test_comments.rb
97
+ - test/test_constructor.rb
98
+ - test/test_deepmerge.rb
99
+ - test/test_erb_array.rb
100
+ - test/test_erb_hash.rb
101
+ - test/test_erb_empty.rb
102
+ - test/test_erb_multi.rb
103
+ - test/test_erb.rb
104
+ - test/test_files.rb
105
+ - test/test_invalid.rb
106
+ - test/test_multi.rb
107
+ - test/test_tohash.rb
108
+ - .gemtest
109
+ homepage: https://github.com/jf647/LayeredYAMLConfig
110
+ licenses:
111
+ - MIT
112
+ post_install_message:
113
+ rdoc_options:
114
+ - --main
115
+ - README.txt
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ! '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ segments:
125
+ - 0
126
+ hash: -1009558789286844075
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ none: false
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ segments:
134
+ - 0
135
+ hash: -1009558789286844075
136
+ requirements: []
137
+ rubyforge_project: layeredyamlconfig
138
+ rubygems_version: 1.8.23
139
+ signing_key:
140
+ specification_version: 3
141
+ summary: LayeredYAMLConfig provides a simple config file that supports multiple layers
142
+ test_files:
143
+ - test/test_addlayer.rb
144
+ - test/test_clear.rb
145
+ - test/test_comments.rb
146
+ - test/test_constructor.rb
147
+ - test/test_deepmerge.rb
148
+ - test/test_erb.rb
149
+ - test/test_erb_array.rb
150
+ - test/test_erb_empty.rb
151
+ - test/test_erb_hash.rb
152
+ - test/test_erb_multi.rb
153
+ - test/test_files.rb
154
+ - test/test_invalid.rb
155
+ - test/test_multi.rb
156
+ - test/test_tohash.rb