dry-config 1.2.6 → 1.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c1990adea4a24a82fc97e272746647443f7c6139
4
- data.tar.gz: cda3cf6ba6aee62afa5d32f8c44a5926a5bf3150
3
+ metadata.gz: d16427dc70a79719b406e9345b50628b7bf7834f
4
+ data.tar.gz: d42226dd7db42322f7dc016c4bfe0c6db88480a9
5
5
  SHA512:
6
- metadata.gz: 11e050abd84ac329bc233f9e9f97402fda4d567ab1cf9a58155c6fd2a8f564b83a2982e4d6d3adedcafdae982be1f2809f9127970bb803ba5ae03d6fc746de5c
7
- data.tar.gz: 1fe0a7980e19eb86899541641b29537489fdc1f26ba6c599b9e2a862072695d36d82a66fb33a345c0f70c944bdc02f8ed4a576671f0402b691b41dfa25038490
6
+ metadata.gz: 2d8b7ada2bcac7afef61c6939180c454890c2e31691a6cc8ffe1d404b6d1309a6011d700b0b5fba5fbbe1ea654e254b9f6dd2a7458c39dd0721f767135409ef2
7
+ data.tar.gz: 1d26c0490fdee32ae4a105ed6090d58acb11ebfaa77b2801c8edffb779be22a3428206c3098afafc15abfad8ac5ecbeabdd140e03778bbade700a9f356948f54
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # dry-config
2
- [![Gem Version](https://badge.fury.io/rb/elastic-beanstalk.svg)](https://rubygems.org/gems/dry-config)
3
- [![Build Status](https://travis-ci.org/rosskevin/sms-spec.svg)](https://travis-ci.org/alienfast/dry-config)
4
- [![Code Climate](https://codeclimate.com/github/rosskevin/sms-spec/badges/gpa.svg)](https://codeclimate.com/github/alienfast/dry-config)
2
+ [![Gem Version](https://badge.fury.io/rb/dry-config.svg)](https://rubygems.org/gems/dry-config)
3
+ [![Build Status](https://travis-ci.org/alienfast/dry-config.svg)](https://travis-ci.org/alienfast/dry-config)
4
+ [![Code Climate](https://codeclimate.com/github/alienfast/dry-config/badges/gpa.svg)](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.
@@ -40,39 +40,52 @@ module Dry
40
40
  clear
41
41
  end
42
42
 
43
- # This is the main point of entry - we call #load! and provide
44
- # a name of the file to read as it's argument. We can also pass in some
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
- # save these in case we #reload
56
- @environment = environment
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
- @configuration.deeper_merge! resolve_config(environment, filename)
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
@@ -1,5 +1,5 @@
1
1
  module Dry
2
2
  module Config
3
- VERSION = '1.2.6'
3
+ VERSION = '1.2.7'
4
4
  end
5
5
  end
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.6
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-14 00:00:00.000000000 Z
11
+ date: 2015-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler