complex_config 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/TODO.md +1 -1
- data/VERSION +1 -1
- data/complex_config.gemspec +4 -4
- data/lib/complex_config/provider.rb +4 -1
- data/lib/complex_config/settings.rb +9 -1
- data/lib/complex_config/version.rb +1 -1
- data/spec/complex_config/provider_spec.rb +3 -1
- data/spec/complex_config/settings_spec.rb +11 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ddfcff0f6eab915c13c8bf06ddae6946aee9008
|
4
|
+
data.tar.gz: 5224f281eb931e9cd8a06e9fc3108f6f156e81e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42892fa8c5b2cd0bf2cebcc9cbe562cdc30bfb276cffe7edee8d82f659733b3e5ff4b5a99f1d65f587d15e1ec069b951cfb5175b4231919fabfd4b00f9d9be52
|
7
|
+
data.tar.gz: fae5fb237475efa269217bfc837f66c5bb45597e21f0bd15ba381134e416eedc50ec1155a8278218024f747533456eb6eaeba753e45f698d76d8be7064ffdb1a
|
data/README.md
CHANGED
data/TODO.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/complex_config.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: complex_config 0.1.
|
2
|
+
# stub: complex_config 0.1.1 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "complex_config"
|
6
|
-
s.version = "0.1.
|
6
|
+
s.version = "0.1.1"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib"]
|
10
10
|
s.authors = ["Florian Frank"]
|
11
|
-
s.date = "
|
11
|
+
s.date = "2015-01-01"
|
12
12
|
s.description = "This library allows you to access configuration files via a simple interface"
|
13
13
|
s.email = "flori@ping.de"
|
14
14
|
s.extra_rdoc_files = ["README.md", "lib/complex_config.rb", "lib/complex_config/errors.rb", "lib/complex_config/plugins.rb", "lib/complex_config/plugins/enable.rb", "lib/complex_config/plugins/money.rb", "lib/complex_config/plugins/uri.rb", "lib/complex_config/provider.rb", "lib/complex_config/rude.rb", "lib/complex_config/settings.rb", "lib/complex_config/shortcuts.rb", "lib/complex_config/version.rb"]
|
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.homepage = "https://github.com/flori/complex_config"
|
17
17
|
s.licenses = ["Apache-2.0"]
|
18
18
|
s.rdoc_options = ["--title", "ComplexConfig -- configuration library", "--main", "README.md"]
|
19
|
-
s.rubygems_version = "2.
|
19
|
+
s.rubygems_version = "2.2.2"
|
20
20
|
s.summary = "configuration library"
|
21
21
|
s.test_files = ["spec/complex_config/plugins_spec.rb", "spec/complex_config/provider_spec.rb", "spec/complex_config/settings_spec.rb", "spec/complex_config/shortcuts_spec.rb", "spec/spec_helper.rb"]
|
22
22
|
|
@@ -25,7 +25,13 @@ class ComplexConfig::Settings < JSON::GenericObject
|
|
25
25
|
|
26
26
|
def to_h
|
27
27
|
each_with_object({}) do |(k, v), h|
|
28
|
-
h[k] =
|
28
|
+
h[k] = if Array === v
|
29
|
+
v.to_ary.map { |x| (x.ask_and_send(:to_h) rescue x) || x }
|
30
|
+
elsif v.respond_to?(:to_h)
|
31
|
+
v.ask_and_send(:to_h) rescue v
|
32
|
+
else
|
33
|
+
v
|
34
|
+
end
|
29
35
|
end
|
30
36
|
end
|
31
37
|
|
@@ -33,6 +39,8 @@ class ComplexConfig::Settings < JSON::GenericObject
|
|
33
39
|
to_h.to_yaml
|
34
40
|
end
|
35
41
|
|
42
|
+
alias to_ary to_a
|
43
|
+
|
36
44
|
alias inspect to_s
|
37
45
|
|
38
46
|
def deep_freeze
|
@@ -113,11 +113,13 @@ RSpec.describe ComplexConfig::Provider do
|
|
113
113
|
|
114
114
|
it 'can flush loaded configurations' do
|
115
115
|
expect(provider['config']).to be_a ComplexConfig::Settings
|
116
|
+
result = nil
|
116
117
|
expect {
|
117
|
-
provider.flush_cache
|
118
|
+
result = provider.flush_cache
|
118
119
|
}.to change {
|
119
120
|
provider.instance.__send__(:__memoize_cache__).size
|
120
121
|
}.by(-1)
|
122
|
+
expect(result).to be_a ComplexConfig::Provider
|
121
123
|
end
|
122
124
|
end
|
123
125
|
|
@@ -39,6 +39,12 @@ RSpec.describe ComplexConfig::Settings do
|
|
39
39
|
:qux: quux
|
40
40
|
EOT
|
41
41
|
end
|
42
|
+
|
43
|
+
it 'can be array like (first level only), so puts still works' do
|
44
|
+
expect(settings).to respond_to :to_ary
|
45
|
+
expect(settings.to_ary).to eq [[:foo, settings.foo]]
|
46
|
+
end
|
47
|
+
|
42
48
|
it 'raises exception if expected attribute is missing' do
|
43
49
|
pending "still doesn't work"
|
44
50
|
expect { settings.nix }.to raise_error(ComplexConfig::AttributeMissing)
|
@@ -50,5 +56,10 @@ EOT
|
|
50
56
|
expect(settings.foo.attribute_set?(:baz)).to eq false
|
51
57
|
#expect(settings.foo.baz?).to be_falsy
|
52
58
|
end
|
59
|
+
|
60
|
+
it 'handles arrays correctly' do
|
61
|
+
settings = ComplexConfig::Settings[ary: [ 1, { hsh: 2 }, 3 ]]
|
62
|
+
expect(settings.to_h).to eq(ary: [ 1, { hsh: 2 }, 3 ])
|
63
|
+
end
|
53
64
|
end
|
54
65
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: complex_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gem_hadar
|
@@ -178,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
178
178
|
version: '0'
|
179
179
|
requirements: []
|
180
180
|
rubyforge_project:
|
181
|
-
rubygems_version: 2.
|
181
|
+
rubygems_version: 2.2.2
|
182
182
|
signing_key:
|
183
183
|
specification_version: 4
|
184
184
|
summary: configuration library
|