config_reader 2.0.0 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +4 -3
- data/CHANGELOG.md +63 -0
- data/Gemfile.lock +30 -21
- data/Rakefile +0 -6
- data/checksums/config_reader-2.0.2.gem.sha512 +1 -0
- data/config_reader.gemspec +1 -6
- data/lib/config_reader/version.rb +1 -1
- data/lib/config_reader.rb +12 -4
- data/spec/config_reader_spec.rb +21 -21
- data/spec/spec_helper.rb +1 -1
- metadata +11 -25
- data/History.rdoc +0 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d62b191e4d30a81325a11a994d3d663eb2f528bc02307731baae267f2fa08948
|
4
|
+
data.tar.gz: ad668aaecbf1670c81f11d277caa7567630d241b0ee6f94cef5d76c2121001b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06e2530d3e104ecc1251283aa2e85b9d0a26b4f42eaf8478c8ec34d6d85e2c9a65ba1f0c3da7dec5b75e276591f7dde37fd19ee1aae0a9c8e866fe0852066c71
|
7
|
+
data.tar.gz: 63cbd8684f90f35a78c42b91ddb6f88872704b8c5468d5f0d485672c601d73105b2fb11c9083458112030101d5a854cda1f4d2d43723f785ca6d119bd7051560
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
### 2.0.2 2023-03-11
|
2
|
+
|
3
|
+
- remove deep-merge dependency
|
4
|
+
|
5
|
+
### 2.0.1 2010-03-19
|
6
|
+
|
7
|
+
- update dependencies
|
8
|
+
|
9
|
+
### 1.0.5 2018-02-01
|
10
|
+
|
11
|
+
- pass ignore_missing_keys to nested hashes during conversion
|
12
|
+
|
13
|
+
### 1.0.4 2018-02-01
|
14
|
+
|
15
|
+
- add a config option for Key Error behavior
|
16
|
+
|
17
|
+
### 1.0.3 2017-06-20
|
18
|
+
|
19
|
+
- add the deep_merge gem so all keys don't need to be duplicated across env sections
|
20
|
+
|
21
|
+
### 0.0.9 2012-02-03
|
22
|
+
|
23
|
+
- Stop abusing Hash, it's not nice
|
24
|
+
- convert all keys to symbols internally
|
25
|
+
- move to a bundler style gem
|
26
|
+
|
27
|
+
### 0.0.8 2011-05-12
|
28
|
+
|
29
|
+
- Silence RAILS_ENV deprecation, thanks jeanmartin
|
30
|
+
|
31
|
+
### 0.0.7 2010-02-14
|
32
|
+
|
33
|
+
- moved to jeweler
|
34
|
+
- removed the annoying post install message
|
35
|
+
- updated specs
|
36
|
+
|
37
|
+
### 0.0.6 2009-04-02
|
38
|
+
|
39
|
+
- handle keys as ['foo'], [:foo] and .foo for real this time
|
40
|
+
- return nil on non-existent key instead of error
|
41
|
+
|
42
|
+
### 0.0.5 2009-01-29
|
43
|
+
|
44
|
+
- handle keys as ['foo'], [:foo] and .foo
|
45
|
+
- return nil on non-existent key instead of error
|
46
|
+
|
47
|
+
### 0.0.4 2008-12-08
|
48
|
+
|
49
|
+
- fix the environment merging issue, for real this time
|
50
|
+
|
51
|
+
### 0.0.3 2008-12-02
|
52
|
+
|
53
|
+
- fix the environment merging issue
|
54
|
+
|
55
|
+
### 0.0.2 2008-09-10
|
56
|
+
|
57
|
+
- have find_config return the file if it exists instead of looking in . and
|
58
|
+
./config
|
59
|
+
|
60
|
+
### 0.0.1 2008-08-06
|
61
|
+
|
62
|
+
- 1 major enhancement:
|
63
|
+
- Initial release
|
data/Gemfile.lock
CHANGED
@@ -1,40 +1,49 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
config_reader (2.0.
|
5
|
-
deep_merge
|
4
|
+
config_reader (2.0.2)
|
6
5
|
|
7
6
|
GEM
|
8
7
|
remote: http://rubygems.org/
|
9
8
|
specs:
|
10
9
|
arrayfields (4.9.2)
|
11
10
|
chronic (0.10.2)
|
12
|
-
coderay (1.1.
|
11
|
+
coderay (1.1.3)
|
13
12
|
coerce (0.0.8)
|
14
13
|
chronic (>= 0.6.2)
|
15
|
-
|
16
|
-
fattr (2.
|
14
|
+
diff-lcs (1.5.0)
|
15
|
+
fattr (2.4.0)
|
17
16
|
highline (1.7.10)
|
18
|
-
main (6.
|
19
|
-
arrayfields (~> 4.
|
20
|
-
chronic (~> 0.
|
21
|
-
fattr (~> 2.
|
22
|
-
map (~> 6.
|
17
|
+
main (6.3.0)
|
18
|
+
arrayfields (~> 4.9, >= 4.9.2)
|
19
|
+
chronic (~> 0.10, >= 0.10.2)
|
20
|
+
fattr (~> 2.4, >= 2.4.0)
|
21
|
+
map (~> 6.6, >= 6.6.0)
|
23
22
|
map (6.6.0)
|
24
|
-
method_source (0.
|
25
|
-
pry (0.
|
26
|
-
coderay (~> 1.
|
27
|
-
method_source (~> 0
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
23
|
+
method_source (1.0.0)
|
24
|
+
pry (0.14.2)
|
25
|
+
coderay (~> 1.1)
|
26
|
+
method_source (~> 1.0)
|
27
|
+
rake (13.0.6)
|
28
|
+
rspec (3.12.0)
|
29
|
+
rspec-core (~> 3.12.0)
|
30
|
+
rspec-expectations (~> 3.12.0)
|
31
|
+
rspec-mocks (~> 3.12.0)
|
32
|
+
rspec-core (3.12.1)
|
33
|
+
rspec-support (~> 3.12.0)
|
34
|
+
rspec-expectations (3.12.2)
|
35
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
36
|
+
rspec-support (~> 3.12.0)
|
37
|
+
rspec-mocks (3.12.3)
|
38
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
39
|
+
rspec-support (~> 3.12.0)
|
40
|
+
rspec-support (3.12.0)
|
41
|
+
sekrets (1.13.0)
|
32
42
|
coerce (~> 0.0.3)
|
33
43
|
fattr (~> 2.2)
|
34
44
|
highline (~> 1.6)
|
35
45
|
main (~> 6.1)
|
36
46
|
map (~> 6.3)
|
37
|
-
slop (3.5.0)
|
38
47
|
|
39
48
|
PLATFORMS
|
40
49
|
ruby
|
@@ -43,8 +52,8 @@ DEPENDENCIES
|
|
43
52
|
config_reader!
|
44
53
|
pry
|
45
54
|
rake
|
46
|
-
rspec (
|
55
|
+
rspec (~> 3.9)
|
47
56
|
sekrets (~> 1)
|
48
57
|
|
49
58
|
BUNDLED WITH
|
50
|
-
|
59
|
+
2.3.13
|
data/Rakefile
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
ecd65abf0eef2de025cf028a84de56bddeb3f6fae18c78565e8f647a3bc79eec777b542c5de26bb74c1c5f7b5cf2ad6eaf71e8061f3729141ac6d38e48367aa7
|
data/config_reader.gemspec
CHANGED
@@ -11,18 +11,13 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.summary = %q{Provides a way to manage environment specific configuration settings.}
|
12
12
|
s.description = %q{Provides a way to manage environment specific configuration settings.}
|
13
13
|
|
14
|
-
s.rubyforge_project = 'config_reader'
|
15
|
-
|
16
14
|
s.files = `git ls-files`.split("\n")
|
17
15
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
16
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
17
|
s.require_paths = ['lib']
|
20
18
|
|
21
|
-
# specify any dependencies here; for example:
|
22
|
-
s.add_dependency 'deep_merge'
|
23
|
-
|
24
19
|
s.add_development_dependency 'rake'
|
25
|
-
s.add_development_dependency 'rspec', '
|
20
|
+
s.add_development_dependency 'rspec', '~> 3.9'
|
26
21
|
s.add_development_dependency 'sekrets', '~> 1'
|
27
22
|
s.add_development_dependency 'pry'
|
28
23
|
|
data/lib/config_reader.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'config_reader/version'
|
2
2
|
require 'config_reader/magic_hash'
|
3
3
|
require 'yaml'
|
4
|
-
require 'deep_merge'
|
5
4
|
|
6
5
|
begin
|
7
6
|
require 'erb'
|
@@ -83,9 +82,9 @@ class ConfigReader
|
|
83
82
|
env = configuration.environment
|
84
83
|
|
85
84
|
_conf = conf['defaults']
|
86
|
-
|
87
|
-
|
88
|
-
|
85
|
+
deep_merge!(_conf, sekrets['defaults']) if sekrets && sekrets['defaults']
|
86
|
+
deep_merge!(_conf, conf[env]) if conf[env]
|
87
|
+
deep_merge!(_conf, sekrets[env]) if sekrets && sekrets[env]
|
89
88
|
|
90
89
|
MagicHash.convert_hash(_conf, configuration.ignore_missing_keys)
|
91
90
|
end
|
@@ -99,6 +98,15 @@ class ConfigReader
|
|
99
98
|
@configuration ||= Configuration.new
|
100
99
|
end
|
101
100
|
|
101
|
+
def deep_merge!(hash, other_hash)
|
102
|
+
hash.merge!(other_hash) do |key, this_val, other_val|
|
103
|
+
if this_val.is_a?(Hash) && other_val.is_a?(Hash)
|
104
|
+
deep_merge!(this_val, other_val)
|
105
|
+
else
|
106
|
+
other_val
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
102
110
|
end
|
103
111
|
|
104
112
|
class Configuration
|
data/spec/config_reader_spec.rb
CHANGED
@@ -6,13 +6,13 @@ describe "ConfigReader" do
|
|
6
6
|
it "should fail with []=" do
|
7
7
|
expect {
|
8
8
|
TestConfig[:app_name] = 'test_app'
|
9
|
-
}.to raise_error
|
9
|
+
}.to raise_error(ArgumentError)
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should fail with #key =" do
|
13
13
|
expect {
|
14
14
|
TestConfig.app_name = 'test_app'
|
15
|
-
}.to raise_error
|
15
|
+
}.to raise_error(ArgumentError)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -70,39 +70,39 @@ describe "ConfigReader" do
|
|
70
70
|
|
71
71
|
describe "parsing a YAML file" do
|
72
72
|
it "should find values with method_missing" do
|
73
|
-
TestConfig.app_name.
|
73
|
+
expect(TestConfig.app_name).to eq('test_app')
|
74
74
|
end
|
75
75
|
|
76
76
|
it "should find values using [] and a string" do
|
77
|
-
TestConfig['app_name'].
|
77
|
+
expect(TestConfig['app_name']).to eq('test_app')
|
78
78
|
end
|
79
79
|
|
80
80
|
it "should find values using [] and a symbol" do
|
81
|
-
TestConfig[:app_name].
|
81
|
+
expect(TestConfig[:app_name]).to eq('test_app')
|
82
82
|
end
|
83
83
|
|
84
84
|
it "should find nested values using method_missing" do
|
85
|
-
TestConfig.nested_key.value.
|
85
|
+
expect(TestConfig.nested_key.value).to eq('test')
|
86
86
|
end
|
87
87
|
|
88
88
|
it "should find nested values using [] and a symbol" do
|
89
|
-
TestConfig[:nested_key][:value].
|
89
|
+
expect(TestConfig[:nested_key][:value]).to eq('test')
|
90
90
|
end
|
91
91
|
|
92
92
|
it "should find nested values using [] and a string" do
|
93
|
-
TestConfig['nested_key']['value'].
|
93
|
+
expect(TestConfig['nested_key']['value']).to eq('test')
|
94
94
|
end
|
95
95
|
|
96
96
|
it "should not find sekrets only nested values using method_missing" do
|
97
|
-
|
97
|
+
expect { TestConfig.sekrets_only }.to raise_error(KeyError)
|
98
98
|
end
|
99
99
|
|
100
100
|
it "should not find sekrets only nested values using [] and a symbol" do
|
101
|
-
|
101
|
+
expect { TestConfig[:sekrets_only][:value] }.to raise_error(KeyError)
|
102
102
|
end
|
103
103
|
|
104
104
|
it "should not find sekrets only nested values using [] and a string" do
|
105
|
-
|
105
|
+
expect { TestConfig['sekrets_only']['value'] }.to raise_error(KeyError)
|
106
106
|
end
|
107
107
|
|
108
108
|
end
|
@@ -110,43 +110,43 @@ describe "ConfigReader" do
|
|
110
110
|
context 'using sekrets' do
|
111
111
|
describe "parsing a YAML file" do
|
112
112
|
it "should find values with method_missing" do
|
113
|
-
SekretsConfig.app_name.
|
113
|
+
expect(SekretsConfig.app_name).to eq('test_app_sekret')
|
114
114
|
end
|
115
115
|
|
116
116
|
it "should find values using [] and a string" do
|
117
|
-
SekretsConfig['app_name'].
|
117
|
+
expect(SekretsConfig['app_name']).to eq('test_app_sekret')
|
118
118
|
end
|
119
119
|
|
120
120
|
it "should find values using [] and a symbol" do
|
121
|
-
SekretsConfig[:app_name].
|
121
|
+
expect(SekretsConfig[:app_name]).to eq('test_app_sekret')
|
122
122
|
end
|
123
123
|
|
124
124
|
it "should find nested values using method_missing" do
|
125
|
-
SekretsConfig.nested_key.value.
|
125
|
+
expect(SekretsConfig.nested_key.value).to eq('test_sekret')
|
126
126
|
end
|
127
127
|
|
128
128
|
it "should find nested values using [] and a symbol" do
|
129
|
-
SekretsConfig[:nested_key][:value].
|
129
|
+
expect(SekretsConfig[:nested_key][:value]).to eq('test_sekret')
|
130
130
|
end
|
131
131
|
|
132
132
|
it "should find nested values using [] and a string" do
|
133
|
-
SekretsConfig['nested_key']['value'].
|
133
|
+
expect(SekretsConfig['nested_key']['value']).to eq('test_sekret')
|
134
134
|
end
|
135
135
|
|
136
136
|
it "should find sekrets only nested values using method_missing" do
|
137
|
-
SekretsConfig.nested_key.value.
|
137
|
+
expect(SekretsConfig.nested_key.value).to eq('test_sekret')
|
138
138
|
end
|
139
139
|
|
140
140
|
it "should find sekrets only nested values using [] and a symbol" do
|
141
|
-
SekretsConfig[:nested_key][:value].
|
141
|
+
expect(SekretsConfig[:nested_key][:value]).to eq('test_sekret')
|
142
142
|
end
|
143
143
|
|
144
144
|
it "should find sekrets only nested values using [] and a string" do
|
145
|
-
SekretsConfig['nested_key']['value'].
|
145
|
+
expect(SekretsConfig['nested_key']['value']).to eq('test_sekret')
|
146
146
|
end
|
147
147
|
|
148
148
|
it "shouldn't need to have all keys duplicated in the environment section" do
|
149
|
-
SekretsConfig.nested_key.only_in_test_env.
|
149
|
+
expect(SekretsConfig.nested_key.only_in_test_env).to be true
|
150
150
|
end
|
151
151
|
end
|
152
152
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: config_reader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Moen
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: deep_merge
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: rake
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -42,16 +28,16 @@ dependencies:
|
|
42
28
|
name: rspec
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
|
-
- -
|
31
|
+
- - "~>"
|
46
32
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
33
|
+
version: '3.9'
|
48
34
|
type: :development
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
|
-
- -
|
38
|
+
- - "~>"
|
53
39
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
40
|
+
version: '3.9'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: sekrets
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -89,12 +75,13 @@ extra_rdoc_files: []
|
|
89
75
|
files:
|
90
76
|
- ".gitignore"
|
91
77
|
- ".travis.yml"
|
78
|
+
- CHANGELOG.md
|
92
79
|
- Gemfile
|
93
80
|
- Gemfile.lock
|
94
|
-
- History.rdoc
|
95
81
|
- License.txt
|
96
82
|
- README.rdoc
|
97
83
|
- Rakefile
|
84
|
+
- checksums/config_reader-2.0.2.gem.sha512
|
98
85
|
- config_reader.gemspec
|
99
86
|
- lib/config_reader.rb
|
100
87
|
- lib/config_reader/magic_hash.rb
|
@@ -125,9 +112,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
112
|
- !ruby/object:Gem::Version
|
126
113
|
version: '0'
|
127
114
|
requirements: []
|
128
|
-
|
129
|
-
|
130
|
-
signing_key:
|
115
|
+
rubygems_version: 3.2.33
|
116
|
+
signing_key:
|
131
117
|
specification_version: 4
|
132
118
|
summary: Provides a way to manage environment specific configuration settings.
|
133
119
|
test_files:
|
data/History.rdoc
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
== 1.0.5 2018-02-01
|
2
|
-
* pass ignore_missing_keys to nested hashes during conversion
|
3
|
-
|
4
|
-
== 1.0.4 2018-02-01
|
5
|
-
* add a config option for Key Error behavior
|
6
|
-
|
7
|
-
== 1.0.3 2017-06-20
|
8
|
-
* add the deep_merge gem so all keys don't need to be duplicated across env sections
|
9
|
-
|
10
|
-
== 0.0.9 2012-02-03
|
11
|
-
* Stop abusing Hash, it's not nice
|
12
|
-
* convert all keys to symbols internally
|
13
|
-
* move to a bundler style gem
|
14
|
-
|
15
|
-
== 0.0.8 2011-05-12
|
16
|
-
* Silence RAILS_ENV deprecation, thanks jeanmartin
|
17
|
-
|
18
|
-
== 0.0.7 2010-02-14
|
19
|
-
* moved to jeweler
|
20
|
-
* removed the annoying post install message
|
21
|
-
* updated specs
|
22
|
-
|
23
|
-
== 0.0.6 2009-04-02
|
24
|
-
* handle keys as ['foo'], [:foo] and .foo for real this time
|
25
|
-
* return nil on non-existent key instead of error
|
26
|
-
|
27
|
-
== 0.0.5 2009-01-29
|
28
|
-
* handle keys as ['foo'], [:foo] and .foo
|
29
|
-
* return nil on non-existent key instead of error
|
30
|
-
|
31
|
-
== 0.0.4 2008-12-08
|
32
|
-
* fix the environment merging issue, for real this time
|
33
|
-
|
34
|
-
== 0.0.3 2008-12-02
|
35
|
-
* fix the environment merging issue
|
36
|
-
|
37
|
-
== 0.0.2 2008-09-10
|
38
|
-
* have find_config return the file if it exists instead of looking in . and
|
39
|
-
./config
|
40
|
-
|
41
|
-
== 0.0.1 2008-08-06
|
42
|
-
|
43
|
-
* 1 major enhancement:
|
44
|
-
* Initial release
|