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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be1bf6c1cc5c0472312df63b9f4e9b5d2165b659
4
- data.tar.gz: 9234cf89ba86ed15fdc24041000ee334340d3ccf
3
+ metadata.gz: 6ddfcff0f6eab915c13c8bf06ddae6946aee9008
4
+ data.tar.gz: 5224f281eb931e9cd8a06e9fc3108f6f156e81e4
5
5
  SHA512:
6
- metadata.gz: 47801efebe328219554dff8380be0db7098f430d2f913b461999fae3513f01ecab0a67300060222311a8cb0abc0e2c3d81e3017cb289f8d87b28b571f1a8eff6
7
- data.tar.gz: 32a4b840c5ff2ab5a89a00b972f3efdf295bfb0cc4d2dec41bd6731d6595956036bec2a1e82af7b27ae490f89ceb4da815600afaf9b188e0a69261447b974bd2
6
+ metadata.gz: 42892fa8c5b2cd0bf2cebcc9cbe562cdc30bfb276cffe7edee8d82f659733b3e5ff4b5a99f1d65f587d15e1ec069b951cfb5175b4231919fabfd4b00f9d9be52
7
+ data.tar.gz: fae5fb237475efa269217bfc837f66c5bb45597e21f0bd15ba381134e416eedc50ec1155a8278218024f747533456eb6eaeba753e45f698d76d8be7064ffdb1a
data/README.md CHANGED
@@ -114,6 +114,8 @@ Here is the `ComplexConfig::Plugins::MONEY` plugin for example:
114
114
 
115
115
  ## Changes
116
116
 
117
+ * 2015-01-01 Release 0.1.1
118
+ * Some small fixes for handling of arrays
117
119
  * 2014-12-15 Release 0.1.0
118
120
  * Freeze configuration by default.
119
121
 
data/TODO.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # TODO
2
2
 
3
- - Cache the plugin results?
4
3
  - Figure out why rspec don't like my double dispatch.
4
+ - Improve string representation of settings
5
5
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: complex_config 0.1.0 ruby lib
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.0"
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 = "2014-12-15"
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.4.4"
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
 
@@ -53,7 +53,10 @@ class ComplexConfig::Provider
53
53
  end
54
54
  memoize_method :[]
55
55
 
56
- alias flush_cache memoize_cache_clear
56
+ def flush_cache
57
+ memoize_cache_clear
58
+ self
59
+ end
57
60
 
58
61
  def evaluate(pathname)
59
62
  data = File.read pathname
@@ -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] = v.ask_and_send(:to_h) || v
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
@@ -1,6 +1,6 @@
1
1
  module ComplexConfig
2
2
  # ComplexConfig version
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.1'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
@@ -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.0
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: 2014-12-15 00:00:00.000000000 Z
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.4.4
181
+ rubygems_version: 2.2.2
182
182
  signing_key:
183
183
  specification_version: 4
184
184
  summary: configuration library