complex_config 0.9.2 → 0.10.0

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: 7b1af4cc8ef65b2df9100287771ed6e3ad052596
4
- data.tar.gz: dd272611b5441ba50d402fbfad6aa5e0682e34c5
3
+ metadata.gz: 7c31636252c684eb2cc7795caec9d106839776b7
4
+ data.tar.gz: 2670fd9265acf9c09e9ee3d861c97c48693b8146
5
5
  SHA512:
6
- metadata.gz: 40ab4210c5208645b12725b37cc90f399abf0049211a6aa90bc62ee2b497ced2771180361ade0b57d534850ec2fb818cf12a9cbe22233ed7238fc0fa2699a63f
7
- data.tar.gz: 965da0cdbecbf375c877f1da1a1a48ec8b822002479ece2d8ff99288f9b5c0de8ac01892661f4e6a7681de6307698cb9f7bba9aafface65c16a528c5e01bf1d1
6
+ metadata.gz: 8e22fac36b063ddfda658354fb6876949a9fa5e9c87659fd9a2b46e709c3beb6fd9bf857334c9cbe372629dae6c9c4180ff05aa86e19ec4500ed4b301a8696a7
7
+ data.tar.gz: 9959e033efcccb41b2d110ae01633b4a1e602b7bdce44dc21a3a852005c0df9b5ea2f429cddb8ef28cd5c93e47632f8ff7b43b81f31f7009bfb545357ba7dd57
data/README.md CHANGED
@@ -144,6 +144,8 @@ Here is the `ComplexConfig::Plugins::MONEY` plugin for example:
144
144
 
145
145
  ## Changes
146
146
 
147
+ * 2017-02-02 Release 0.10.0
148
+ * `cc.foo?`/`complex_config.foo?` returns config or nil (when not existant)
147
149
  * 2017-01-23 Release 0.9.2
148
150
  * Improve performance for proxy objects
149
151
  * 2016-11-22 Release 0.9.1
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.2
1
+ 0.10.0
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: complex_config 0.9.2 ruby lib
2
+ # stub: complex_config 0.10.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "complex_config".freeze
6
- s.version = "0.9.2"
6
+ s.version = "0.10.0"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
10
10
  s.authors = ["Florian Frank".freeze]
11
- s.date = "2017-01-23"
11
+ s.date = "2017-02-02"
12
12
  s.description = "This library allows you to access configuration files via a simple interface".freeze
13
13
  s.email = "flori@ping.de".freeze
14
14
  s.extra_rdoc_files = ["README.md".freeze, "lib/complex_config.rb".freeze, "lib/complex_config/config.rb".freeze, "lib/complex_config/errors.rb".freeze, "lib/complex_config/plugins.rb".freeze, "lib/complex_config/plugins/enable.rb".freeze, "lib/complex_config/plugins/money.rb".freeze, "lib/complex_config/plugins/uri.rb".freeze, "lib/complex_config/provider.rb".freeze, "lib/complex_config/provider/shortcuts.rb".freeze, "lib/complex_config/proxy.rb".freeze, "lib/complex_config/railtie.rb".freeze, "lib/complex_config/rude.rb".freeze, "lib/complex_config/settings.rb".freeze, "lib/complex_config/shortcuts.rb".freeze, "lib/complex_config/version.rb".freeze]
@@ -73,6 +73,12 @@ class ComplexConfig::Provider
73
73
  end
74
74
  memoize method: :[]
75
75
 
76
+ def exist?(name)
77
+ !!config(pathname(name), name)
78
+ rescue ComplexConfig::ConfigurationFileMissing
79
+ false
80
+ end
81
+
76
82
  def proxy(env = nil)
77
83
  ComplexConfig::Proxy.new(env)
78
84
  end
@@ -18,19 +18,34 @@ module ComplexConfig
18
18
  end
19
19
 
20
20
  def method_missing(name, *args)
21
- config = ::ComplexConfig::Provider[name]
22
- (class << self; self; end).class_eval do
23
- define_method(name) do |env = nil|
24
- if env
25
- config[env]
26
- elsif @env
27
- config[@env]
28
- else
29
- config
21
+ if name =~ /\?\z/
22
+ method_name, name = name, $`
23
+ exist = ::ComplexConfig::Provider.exist?(name)
24
+ (class << self; self; end).class_eval do
25
+ define_method(method_name) do |env = nil|
26
+ if exist
27
+ __send__(name, *args)
28
+ else
29
+ nil
30
+ end
30
31
  end
31
32
  end
33
+ __send__(method_name, *args)
34
+ else
35
+ config = ::ComplexConfig::Provider[name]
36
+ (class << self; self; end).class_eval do
37
+ define_method(name) do |env = nil|
38
+ if env
39
+ config[env]
40
+ elsif @env
41
+ config[@env]
42
+ else
43
+ config
44
+ end
45
+ end
46
+ end
47
+ __send__(name, *args)
32
48
  end
33
- __send__(name, *args)
34
49
  end
35
50
  end
36
51
  end
@@ -1,6 +1,6 @@
1
1
  module ComplexConfig
2
2
  # ComplexConfig version
3
- VERSION = '0.9.2'
3
+ VERSION = '0.10.0'
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:
@@ -18,6 +18,11 @@ RSpec.describe 'shortcuts' do
18
18
  expect(cc.config.name_prefix).to eq :config
19
19
  end
20
20
 
21
+ it 'returns config or nil for ?-methods' do
22
+ expect(cc.config?).to eq cc.config
23
+ expect(cc.foo?).to be_nil
24
+ end
25
+
21
26
  it 'can be reloaded via shortcut' do
22
27
  expect(ComplexConfig::Provider).to receive(:flush_cache)
23
28
  complex_config.reload
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.9.2
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-23 00:00:00.000000000 Z
11
+ date: 2017-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_hadar