dry-config 1.1.1 → 1.1.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 +58 -58
- data/lib/dry/config/base.rb +1 -1
- data/lib/dry/config/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 815f725119b9da037800fb9bcb685e616c4f670c
|
4
|
+
data.tar.gz: 6973bbe93f7cd1349614c1925ff7441c5e689f76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba9aab3171b96b1d3b0798c02cd8f283ecf7238182c3c5de05c0dcbec637bb431ad6cda43142a3a1034b84e530e45903118b12b8ada9e1801a1effeab92e7693
|
7
|
+
data.tar.gz: 67caa764e2f9c0e222e38088bb56b1d9ba24d29a77a10ed467a6e282b4efaa79b2c19ffc4d5e21b6464db89bdd8af1a6a37adf1d172cdb293fd8685d0b8b6422
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# dry-config
|
2
2
|
|
3
3
|
Simple base class for DRY configurations configurations that can be loaded from multiple overriding yml files.
|
4
4
|
|
@@ -28,82 +28,82 @@ Or install it yourself as:
|
|
28
28
|
Note this sample uses the `Singleton` pattern, which is useful but not required.
|
29
29
|
|
30
30
|
```ruby
|
31
|
-
|
32
|
-
|
31
|
+
require 'singleton'
|
32
|
+
require 'dry/config'
|
33
|
+
|
34
|
+
class AcmeConfig < Dry::Config::Base
|
35
|
+
|
36
|
+
# (optional) make this the only instance
|
37
|
+
include Singleton
|
33
38
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
package: {
|
46
|
-
verbose: false
|
47
|
-
},
|
48
|
-
options: {}
|
49
|
-
}
|
50
|
-
end
|
39
|
+
# seed the sensible defaults here
|
40
|
+
def seed_default_configuration
|
41
|
+
|
42
|
+
@configuration = {
|
43
|
+
environment: nil,
|
44
|
+
strategy: :blue_green,
|
45
|
+
package: {
|
46
|
+
verbose: false
|
47
|
+
},
|
48
|
+
options: {}
|
49
|
+
}
|
51
50
|
end
|
51
|
+
end
|
52
52
|
```
|
53
53
|
|
54
54
|
### Step 2. Write a yml config file
|
55
55
|
|
56
56
|
```yaml
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
57
|
+
# sample config demonstrating multi-environment override
|
58
|
+
---
|
59
|
+
app: acme
|
60
|
+
title: Acme Holdings, LLC
|
61
|
+
#---
|
62
|
+
options:
|
63
|
+
aws:elasticbeanstalk:application:environment:
|
64
|
+
RAILS_ENV: foobar
|
65
|
+
|
66
|
+
aws:autoscaling:launchconfiguration:
|
67
|
+
InstanceType: foo
|
68
|
+
|
69
|
+
#---
|
70
|
+
development:
|
71
|
+
strategy: inplace-update
|
72
|
+
package:
|
73
|
+
verbose: true
|
74
|
+
options:
|
75
|
+
aws:autoscaling:launchconfiguration:
|
76
|
+
InstanceType: t1.micro
|
77
|
+
aws:elasticbeanstalk:application:environment:
|
78
|
+
RAILS_ENV: development
|
79
|
+
|
80
|
+
#---
|
81
|
+
production:
|
82
|
+
options:
|
83
|
+
aws:autoscaling:launchconfiguration:
|
84
|
+
InstanceType: t1.large
|
85
|
+
aws:elasticbeanstalk:application:environment:
|
86
|
+
RAILS_ENV: production
|
87
87
|
```
|
88
88
|
|
89
89
|
### Step 3. Load your config
|
90
90
|
Note that multiple files can be loaded and overriden. A nil environment is also possible.
|
91
91
|
|
92
92
|
```ruby
|
93
|
-
|
93
|
+
AcmeConfig.instance.load!(:production, 'path_to/acme.yml')
|
94
94
|
```
|
95
95
|
|
96
96
|
### Step 4. Use the values
|
97
97
|
Note that all keys are symbolized upon loading.
|
98
98
|
|
99
99
|
```ruby
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
100
|
+
config = Acme.config.instance
|
101
|
+
config.load!(:production, 'path_to/acme.yml')
|
102
|
+
|
103
|
+
config.app # acme
|
104
|
+
config.title # Acme Holdings, LLC
|
105
|
+
config.strategy # :blue_green,
|
106
|
+
config.options[:'aws:autoscaling:launchconfiguration'][:InstanceType] # t1.large
|
107
107
|
```
|
108
108
|
|
109
109
|
## Other options
|
data/lib/dry/config/base.rb
CHANGED
data/lib/dry/config/version.rb
CHANGED