dry-config 1.1.6 → 1.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c5bdac42ba070c133bd4c02d1675b3f5d15a34eb
4
- data.tar.gz: c640bf904bdce15098be492e2e7ff8dba96f9aed
3
+ metadata.gz: fe732b8904f1e9a3fa01f901618ea841b24fa35e
4
+ data.tar.gz: b5bd5f10972da2af169f21c71c12d174e8d3c2ce
5
5
  SHA512:
6
- metadata.gz: 81fa0b488861ccd5fd22141febda0113bc2cd54534e0d6ba2e7b95e992fed47800ef8cf095d6c1324984e2cdfa430eb4f8cf0d62acf083fb81b146353aeb4591
7
- data.tar.gz: 6580dc6edf6eb2c201f54942c25be63df1425ec120f4bee0f388e282cc91bc10f8e711e6d708f06c7581b332ace7e5d9f9895b3755764d9b163e1834bfc27b6d
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
- # seed the sensible defaults here
47
- def seed_default_configuration
48
-
49
- @configuration = {
50
- environment: nil,
51
- strategy: :blue_green,
52
- package: {
53
- verbose: false
54
- },
55
- options: {}
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
  ```
@@ -18,17 +18,20 @@ module Dry
18
18
  attr_reader :filenames
19
19
 
20
20
  def initialize(options = {})
21
- @options = {interpolation: true, symbolize: true}.merge 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
- seed_default_configuration
28
+ @default_configuration = @options[:default_configuration]
24
29
 
25
30
  # used for pruning initial base set. See #load!
26
- @potential_environments = [:development, :test, :staging, :production]
27
- end
31
+ @potential_environments = @options[:potential_environments]
28
32
 
29
- def seed_default_configuration
30
- # override and seed the sensible defaults here
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
- if environment
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
- seed_default_configuration
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)
@@ -1,5 +1,5 @@
1
1
  module Dry
2
2
  module Config
3
- VERSION = '1.1.6'
3
+ VERSION = '1.2.0'
4
4
  end
5
5
  end
@@ -6,16 +6,19 @@ describe Dry::Config::Base do
6
6
  class AcmeConfig < Dry::Config::Base
7
7
  include Singleton
8
8
 
9
- def seed_default_configuration
10
- # seed the sensible defaults here
11
- @configuration = {
12
- environment: nil,
13
- strategy: :blue_green,
14
- package: {
15
- verbose: false
16
- },
17
- options: {}
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.1.6
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-10 00:00:00.000000000 Z
11
+ date: 2015-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler