dry-config 1.2.4 → 1.2.5
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/dry-config.gemspec +1 -0
- data/lib/dry/config.rb +1 -0
- data/lib/dry/config/base.rb +2 -21
- data/lib/dry/config/version.rb +1 -1
- data/spec/dry/config/deep_merge_spec.rb +42 -0
- data/spec/dry/config/docker-rails.yml +72 -0
- metadata +19 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c1737b29253538d7bf15cd0e02bc7f2d34c4b33
|
4
|
+
data.tar.gz: 051fd285d4b11930896fb44fe2c331bdc61630a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 237dec289c8886e1c80f7437bd9d03554f93706bb6c5576544a0fd4fdb9e0869c895e8f6d1355c34fdcf5bb1fac95fa7caee665055928284b70c10f108250c82
|
7
|
+
data.tar.gz: 0c0229fbbbc42e414959bd70433cdeeec726a3382ba0c5a4308102444718fc96a78d2af0464e5b7a614071dea87dc56bc2a2c61393e63e343658d9a05e46ce8d
|
data/dry-config.gemspec
CHANGED
data/lib/dry/config.rb
CHANGED
@@ -2,6 +2,7 @@ require 'dry/config/version'
|
|
2
2
|
|
3
3
|
module Dry
|
4
4
|
module Config
|
5
|
+
require 'deep_merge/rails_compat' # need to require an explicit rails compatibility https://github.com/danielsdeleo/deep_merge#using-deep_merge-in-rails
|
5
6
|
require 'dry/config/deep_symbolizable'
|
6
7
|
require 'dry/config/base'
|
7
8
|
end
|
data/lib/dry/config/base.rb
CHANGED
@@ -58,7 +58,7 @@ module Dry
|
|
58
58
|
|
59
59
|
filenames.each do |filename|
|
60
60
|
# merge all top level settings with the defaults set in the #init
|
61
|
-
|
61
|
+
@configuration.deeper_merge! resolve_config(environment, filename)
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -82,7 +82,7 @@ module Dry
|
|
82
82
|
environment_settings = environment_settings[environment.to_sym]
|
83
83
|
|
84
84
|
# finally overlay what was provided the settings from the specific environment
|
85
|
-
|
85
|
+
config.deeper_merge! environment_settings
|
86
86
|
end
|
87
87
|
|
88
88
|
config
|
@@ -179,25 +179,6 @@ module Dry
|
|
179
179
|
def interpolate?
|
180
180
|
@options[:interpolation]
|
181
181
|
end
|
182
|
-
|
183
|
-
private
|
184
|
-
|
185
|
-
def deep_merge!(target, overrides)
|
186
|
-
|
187
|
-
raise 'target cannot be nil' if target.nil?
|
188
|
-
raise 'overrides cannot be nil' if overrides.nil?
|
189
|
-
|
190
|
-
merger = proc { |key, v1, v2|
|
191
|
-
if (Hash === v1 && Hash === v2)
|
192
|
-
v1.merge(v2, &merger)
|
193
|
-
elsif (Array === v1 && Array === v2)
|
194
|
-
v1.concat(v2)
|
195
|
-
else
|
196
|
-
v2
|
197
|
-
end
|
198
|
-
}
|
199
|
-
target.merge! overrides, &merger
|
200
|
-
end
|
201
182
|
end
|
202
183
|
end
|
203
184
|
end
|
data/lib/dry/config/version.rb
CHANGED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'singleton'
|
3
|
+
|
4
|
+
describe Dry::Config::Base do
|
5
|
+
|
6
|
+
class DockerRailsConfig < Dry::Config::Base
|
7
|
+
def initialize(options = {})
|
8
|
+
options = {
|
9
|
+
default_configuration: {
|
10
|
+
verbose: false
|
11
|
+
|
12
|
+
}
|
13
|
+
# ,
|
14
|
+
# prune: [:development, :test, :parallel_tests, :staging, :production]
|
15
|
+
}.merge(options)
|
16
|
+
|
17
|
+
super(options)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
subject(:config) { DockerRailsConfig.new }
|
22
|
+
before(:each) {
|
23
|
+
config.clear
|
24
|
+
}
|
25
|
+
|
26
|
+
it 'should deep merge a subordinate array' do
|
27
|
+
|
28
|
+
config.load!(:development, config_file_path)
|
29
|
+
|
30
|
+
links = config[:'docker-compose'][:web][:links]
|
31
|
+
expect(links).to match_array %w(elasticsearch db)
|
32
|
+
|
33
|
+
# ensure no unnecessary environments make it into the resolved configuration
|
34
|
+
expect(config.production).to be_nil
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def config_file_path
|
40
|
+
File.expand_path('../docker-rails.yml', __FILE__)
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
verbose: true
|
2
|
+
|
3
|
+
# local environments need elasticsearch, staging/production connects to existing running instance.
|
4
|
+
elasticsearch: &elasticsearch
|
5
|
+
elasticsearch:
|
6
|
+
image: library/elasticsearch:1.7
|
7
|
+
ports:
|
8
|
+
- "9200:9200"
|
9
|
+
links:
|
10
|
+
- elasticsearch
|
11
|
+
|
12
|
+
development:
|
13
|
+
docker-compose:
|
14
|
+
web:
|
15
|
+
<<: *elasticsearch
|
16
|
+
|
17
|
+
command: >
|
18
|
+
bash -c "
|
19
|
+
echo 'Bundling gems'
|
20
|
+
&& bundle install --jobs 4 --retry 3
|
21
|
+
|
22
|
+
&& echo 'Generating Spring binstubs'
|
23
|
+
&& bundle exec spring binstub --all
|
24
|
+
|
25
|
+
&& echo 'Clearing logs and tmp dirs'
|
26
|
+
&& bundle exec rake log:clear tmp:clear
|
27
|
+
|
28
|
+
&& echo 'Check and wait for database connection'
|
29
|
+
&& bundle exec docker-rails-db-check
|
30
|
+
|
31
|
+
&& echo 'DB rebuild'
|
32
|
+
&& bundle exec rake db:rebuild
|
33
|
+
|
34
|
+
&& echo "Starting app server"
|
35
|
+
&& bundle exec rails s -p 3000
|
36
|
+
|
37
|
+
&& echo 'Setup and start foreman'
|
38
|
+
&& gem install foreman
|
39
|
+
&& foreman start
|
40
|
+
"
|
41
|
+
|
42
|
+
docker-compose:
|
43
|
+
web:
|
44
|
+
build: .
|
45
|
+
working_dir: /project/spec/dummy
|
46
|
+
ports:
|
47
|
+
- "3000:3000"
|
48
|
+
|
49
|
+
volumes:
|
50
|
+
- .:/project
|
51
|
+
|
52
|
+
links:
|
53
|
+
- db
|
54
|
+
|
55
|
+
volumes_from:
|
56
|
+
# Mount the gems data volume container for cached bundler gem files
|
57
|
+
- #{GEMS_VOLUME_NAME}
|
58
|
+
|
59
|
+
# https://docs.docker.com/v1.6/docker-compose/cli/#environment-variables
|
60
|
+
environment:
|
61
|
+
# Tell bundler where to get the files
|
62
|
+
- GEM_HOME=#{GEMS_VOLUME_PATH}
|
63
|
+
|
64
|
+
db:
|
65
|
+
# https://github.com/docker-library/docs/tree/master/mysql
|
66
|
+
image: library/mysql:5.7.6
|
67
|
+
ports:
|
68
|
+
- "3306:3306"
|
69
|
+
|
70
|
+
# https://github.com/docker-library/docs/tree/master/mysql#environment-variables
|
71
|
+
environment:
|
72
|
+
- MYSQL_ALLOW_EMPTY_PASSWORD=true
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Ross
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: deep_merge
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
description: Simple base class for DRY environment based configurations.
|
56
70
|
email:
|
57
71
|
- kevin.ross@alienfast.com
|
@@ -75,9 +89,11 @@ files:
|
|
75
89
|
- lib/dry/config/version.rb
|
76
90
|
- spec/dry/config/acme.yml
|
77
91
|
- spec/dry/config/base_spec.rb
|
92
|
+
- spec/dry/config/deep_merge_spec.rb
|
78
93
|
- spec/dry/config/deep_symbolizable_spec.rb
|
79
94
|
- spec/dry/config/docker-compose-template-simple.yml
|
80
95
|
- spec/dry/config/docker-compose-template.yml
|
96
|
+
- spec/dry/config/docker-rails.yml
|
81
97
|
- spec/dry/config/interpolation_spec.rb
|
82
98
|
- spec/dry/config/white-label/acme.com.yml
|
83
99
|
- spec/dry/config/white-label/base.yml
|
@@ -110,9 +126,11 @@ summary: Simple base class for DRY environment based configurations.
|
|
110
126
|
test_files:
|
111
127
|
- spec/dry/config/acme.yml
|
112
128
|
- spec/dry/config/base_spec.rb
|
129
|
+
- spec/dry/config/deep_merge_spec.rb
|
113
130
|
- spec/dry/config/deep_symbolizable_spec.rb
|
114
131
|
- spec/dry/config/docker-compose-template-simple.yml
|
115
132
|
- spec/dry/config/docker-compose-template.yml
|
133
|
+
- spec/dry/config/docker-rails.yml
|
116
134
|
- spec/dry/config/interpolation_spec.rb
|
117
135
|
- spec/dry/config/white-label/acme.com.yml
|
118
136
|
- spec/dry/config/white-label/base.yml
|