dry-config 1.2.6 → 1.2.7
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 +3 -3
- data/lib/dry/config/base.rb +25 -12
- data/lib/dry/config/version.rb +1 -1
- 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: d16427dc70a79719b406e9345b50628b7bf7834f
|
4
|
+
data.tar.gz: d42226dd7db42322f7dc016c4bfe0c6db88480a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d8b7ada2bcac7afef61c6939180c454890c2e31691a6cc8ffe1d404b6d1309a6011d700b0b5fba5fbbe1ea654e254b9f6dd2a7458c39dd0721f767135409ef2
|
7
|
+
data.tar.gz: 1d26c0490fdee32ae4a105ed6090d58acb11ebfaa77b2801c8edffb779be22a3428206c3098afafc15abfad8ac5ecbeabdd140e03778bbade700a9f356948f54
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# dry-config
|
2
|
-
[](https://rubygems.org/gems/dry-config)
|
3
|
+
[](https://travis-ci.org/alienfast/dry-config)
|
4
|
+
[](https://codeclimate.com/github/alienfast/dry-config)
|
5
5
|
|
6
6
|
|
7
7
|
Simple base class for DRY inheritable configurations that can be loaded from multiple overriding yml files.
|
data/lib/dry/config/base.rb
CHANGED
@@ -40,39 +40,52 @@ module Dry
|
|
40
40
|
clear
|
41
41
|
end
|
42
42
|
|
43
|
-
#
|
44
|
-
#
|
43
|
+
# Load the configuration and save state.
|
44
|
+
#
|
45
|
+
# We call #load! and provide a name of the file to read as it's argument. We can also pass in some
|
45
46
|
# options, but at the moment it's being used to allow per-environment
|
46
47
|
# overrides in Rails
|
47
48
|
def load!(environment, *filenames)
|
48
49
|
|
50
|
+
# save these in case we #reload
|
51
|
+
@environment = environment
|
52
|
+
@filenames = filenames
|
53
|
+
|
54
|
+
# load the configuration
|
55
|
+
@configuration = load_unpruned(environment, *filenames)
|
56
|
+
|
57
|
+
# Prune all known environments so that we end up with the top-level configuration.
|
58
|
+
@prune.each do |env|
|
59
|
+
@configuration.delete(env)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# Load the configuration without saving state. Useful for validation of complex configuration resolution without
|
64
|
+
# altering the existing state.
|
65
|
+
def load_unpruned(environment, *filenames)
|
66
|
+
|
49
67
|
# raise 'Unspecified environment' if environment.nil?
|
50
68
|
raise 'Unspecified filename' if filenames.nil?
|
51
69
|
|
52
70
|
# ensure symbol if symbolize?
|
53
71
|
environment = environment.to_sym if symbolize? && !environment.nil?
|
54
72
|
|
55
|
-
#
|
56
|
-
|
57
|
-
@filenames = filenames
|
73
|
+
# get a clone of the current configuration
|
74
|
+
config = {}.merge @configuration
|
58
75
|
|
59
76
|
filenames.each do |filename|
|
60
77
|
# merge all top level settings with the defaults set in the #init
|
61
|
-
|
78
|
+
config.deeper_merge! resolve_config(environment, filename)
|
62
79
|
end
|
80
|
+
|
81
|
+
config
|
63
82
|
end
|
64
83
|
|
65
84
|
def resolve_config(environment, filename)
|
66
|
-
|
67
85
|
config = load_yaml_file(filename)
|
68
86
|
|
69
87
|
should_overlay_environment = environment && config[environment]
|
70
88
|
|
71
|
-
# Prune all known environments so that we end up with the top-level configuration.
|
72
|
-
@prune.each do |env|
|
73
|
-
config.delete(env)
|
74
|
-
end
|
75
|
-
|
76
89
|
# overlay the specific environment if provided
|
77
90
|
if should_overlay_environment
|
78
91
|
# re-read the file
|
data/lib/dry/config/version.rb
CHANGED
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.2.
|
4
|
+
version: 1.2.7
|
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-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|