econfig 1.0.1 → 1.0.2

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: 3d86ec0882346b8c6b8008617d48044cc1b2f687
4
- data.tar.gz: cfb35e4269f57f3d26a35d873b957b996ef8ec7e
3
+ metadata.gz: 2cea87052bc286ddf6358f088fa55f43496f8781
4
+ data.tar.gz: 884f074a2bde2b167ba897b809bb10e02f2239d9
5
5
  SHA512:
6
- metadata.gz: 66f09880fbdd95b344b4341a0cdb434ac6fc3b7256b617f15f47ebe616eb9a6a358470b1b2911bf94ecb6e2d33e59e49a1d8573b12b722417a1438c4dfdb4c99
7
- data.tar.gz: c0cabef2e2d453280d1d2c797dccfebfc5087dcbfcbf3264c7b6d5986ce405eb460d13479ed1b4b07995e46bc347d71d4680f3fc23811bfd256b3a821a751a02
6
+ metadata.gz: 435d78b9d71c5bcbb41d8869887afe8f661e8f6ffe7747374cfef3dd6e8b3e565b0a4a9c949f701c316e47540c6a40a66e2ce335cd8e224da206e04198409dda
7
+ data.tar.gz: 8f63c476e95c66e8b064a0e63c01c471950b3ec0bdb9220d10c6265abb5698110f3745a6c918570418af2de0294c6ab6662bd161c1cb24d357fa29f3fa4afc87
data/README.md CHANGED
@@ -45,6 +45,11 @@ access optional configuration, which can be nil, use brackets:
45
45
  MyApp.config[:aws_access_key_id]
46
46
  ```
47
47
 
48
+ Sometimes you might want to bypass the strictness requirement in econfig, for
49
+ example if you're running the application as part of a build process. In that
50
+ case you can set the environment variable `ECONFIG_PERMISSIVE`, and econfig
51
+ will not raise errors on missing keys, instead returning `nil`.
52
+
48
53
  ## Configuring options.
49
54
 
50
55
  You can specify configuration through:
@@ -31,5 +31,5 @@ Econfig.instance = Econfig::Configuration.new
31
31
  Econfig.default_write_backend = :memory
32
32
  Econfig.backends.use :memory, Econfig::Memory.new
33
33
  Econfig.backends.use :env, Econfig::ENV.new
34
- Econfig.backends.use :secret, Econfig::YAML.new("config/secret.yml")
34
+ Econfig.backends.use :secrets, Econfig::YAML.new("config/secrets.yml")
35
35
  Econfig.backends.use :yaml, Econfig::YAML.new("config/app.yml")
@@ -30,7 +30,11 @@ module Econfig
30
30
  def method_missing(name, *args)
31
31
  if respond_to?(name)
32
32
  raise ArgumentError, "too many arguments (#{args.length} for 0)" if args.length > 0
33
- fetch(name)
33
+ if ::ENV["ECONFIG_PERMISSIVE"].to_s.empty?
34
+ fetch(name)
35
+ else
36
+ self[name]
37
+ end
34
38
  else
35
39
  super
36
40
  end
@@ -1,3 +1,3 @@
1
1
  module Econfig
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -79,11 +79,28 @@ describe Econfig::Configuration do
79
79
  end
80
80
 
81
81
  describe "#method_missing" do
82
+ after do
83
+ ENV["ECONFIG_PERMISSIVE"] = nil
84
+ end
85
+
82
86
  it "calls fetch for normal methods" do
83
87
  backend.stub(:get).with("foobar").and_return("elephant")
84
88
  config.foobar.should == "elephant"
85
89
  end
86
90
 
91
+ it "raises error if the key can't be found in any backend" do
92
+ backend.stub(:get).with("foobar").and_return(nil)
93
+ other_backend.stub(:get).with("foobar").and_return(nil)
94
+ expect { config.foobar }.to raise_error(Econfig::NotFound)
95
+ end
96
+
97
+ it "returns nil if environment variable bypass is set" do
98
+ ENV["ECONFIG_PERMISSIVE"] = "true"
99
+ backend.stub(:get).with("foobar").and_return(nil)
100
+ other_backend.stub(:get).with("foobar").and_return(nil)
101
+ config.foobar.should be_nil
102
+ end
103
+
87
104
  it "raises NoMethodError for bang methods" do
88
105
  expect { config.foobar! }.to raise_error(NoMethodError)
89
106
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: econfig
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Nicklas
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-27 00:00:00.000000000 Z
12
+ date: 2014-11-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -141,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
141
  version: '0'
142
142
  requirements: []
143
143
  rubyforge_project:
144
- rubygems_version: 2.2.1
144
+ rubygems_version: 2.4.3
145
145
  signing_key:
146
146
  specification_version: 4
147
147
  summary: Congifure Ruby apps