dry-config 1.1.6 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -11
- data/lib/dry/config/base.rb +14 -11
- data/lib/dry/config/version.rb +1 -1
- data/spec/dry/config/base_spec.rb +13 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe732b8904f1e9a3fa01f901618ea841b24fa35e
|
4
|
+
data.tar.gz: b5bd5f10972da2af169f21c71c12d174e8d3c2ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff0a71be24d0dc6f7c119030976cb11f144baf87a3d8fc6e1ccae28038d03794fb8b83de62d1c87475518da52840f7609f0aa0e952df025a717850e25ac7eb05
|
7
|
+
data.tar.gz: fdaaf9786d8ac6bc104e97f1999946010540473aea18922b0ea480e3d03ff7ab6f4a745cf4b82444ab36b150060fe63a8074ae40409dcda62e08cdcc31d422dc
|
data/README.md
CHANGED
@@ -43,17 +43,19 @@ class AcmeConfig < Dry::Config::Base
|
|
43
43
|
# (optional) make this the only instance
|
44
44
|
include Singleton
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
46
|
+
def initialize(options = {})
|
47
|
+
options = {
|
48
|
+
# seed the sensible defaults here (overridable)
|
49
|
+
default_configuration: {
|
50
|
+
environment: nil,
|
51
|
+
strategy: :blue_green,
|
52
|
+
package: {
|
53
|
+
verbose: false
|
54
|
+
},
|
55
|
+
options: {}
|
56
|
+
}}.merge(options)
|
57
|
+
|
58
|
+
super(options)
|
57
59
|
end
|
58
60
|
end
|
59
61
|
```
|
data/lib/dry/config/base.rb
CHANGED
@@ -18,17 +18,20 @@ module Dry
|
|
18
18
|
attr_reader :filenames
|
19
19
|
|
20
20
|
def initialize(options = {})
|
21
|
-
@options = {
|
21
|
+
@options = {
|
22
|
+
interpolation: true,
|
23
|
+
symbolize: true,
|
24
|
+
default_configuration: {},
|
25
|
+
potential_environments: [:development, :test, :staging, :production]
|
26
|
+
}.merge options
|
22
27
|
|
23
|
-
|
28
|
+
@default_configuration = @options[:default_configuration]
|
24
29
|
|
25
30
|
# used for pruning initial base set. See #load!
|
26
|
-
@potential_environments = [:
|
27
|
-
end
|
31
|
+
@potential_environments = @options[:potential_environments]
|
28
32
|
|
29
|
-
|
30
|
-
|
31
|
-
@configuration = {}
|
33
|
+
# setup a default configuration
|
34
|
+
clear
|
32
35
|
end
|
33
36
|
|
34
37
|
# This is the main point of entry - we call #load! and provide
|
@@ -41,9 +44,7 @@ module Dry
|
|
41
44
|
raise 'Unspecified filename' if filenames.nil?
|
42
45
|
|
43
46
|
# ensure symbol
|
44
|
-
|
45
|
-
environment = environment.to_sym unless environment.is_a? Symbol
|
46
|
-
end
|
47
|
+
environment = environment.to_sym unless environment.nil?
|
47
48
|
|
48
49
|
# save these in case we #reload
|
49
50
|
@environment = environment
|
@@ -121,7 +122,9 @@ module Dry
|
|
121
122
|
end
|
122
123
|
|
123
124
|
def clear
|
124
|
-
|
125
|
+
# clone a copy of the default
|
126
|
+
@configuration = {}.merge @default_configuration
|
127
|
+
@configuration.deep_symbolize if @options[:symbolize]
|
125
128
|
end
|
126
129
|
|
127
130
|
def method_missing(name, *args, &block)
|
data/lib/dry/config/version.rb
CHANGED
@@ -6,16 +6,19 @@ describe Dry::Config::Base do
|
|
6
6
|
class AcmeConfig < Dry::Config::Base
|
7
7
|
include Singleton
|
8
8
|
|
9
|
-
def
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
9
|
+
def initialize(options = {})
|
10
|
+
options = {
|
11
|
+
# seed the sensible defaults here (overridable)
|
12
|
+
default_configuration: {
|
13
|
+
environment: nil,
|
14
|
+
strategy: :blue_green,
|
15
|
+
package: {
|
16
|
+
verbose: false
|
17
|
+
},
|
18
|
+
options: {}
|
19
|
+
}}.merge(options)
|
20
|
+
|
21
|
+
super(options)
|
19
22
|
end
|
20
23
|
end
|
21
24
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Ross
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|