econfig 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/lib/econfig.rb +1 -1
- data/lib/econfig/configuration.rb +5 -1
- data/lib/econfig/version.rb +1 -1
- data/spec/configuration_spec.rb +17 -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: 2cea87052bc286ddf6358f088fa55f43496f8781
|
4
|
+
data.tar.gz: 884f074a2bde2b167ba897b809bb10e02f2239d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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:
|
data/lib/econfig.rb
CHANGED
@@ -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 :
|
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
|
-
|
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
|
data/lib/econfig/version.rb
CHANGED
data/spec/configuration_spec.rb
CHANGED
@@ -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.
|
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-
|
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.
|
144
|
+
rubygems_version: 2.4.3
|
145
145
|
signing_key:
|
146
146
|
specification_version: 4
|
147
147
|
summary: Congifure Ruby apps
|