app_config_loader 1.0.1 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a9784e8b7cbbb457d574c16c03a76a8c647de00
4
- data.tar.gz: 8f96083cbcb8493b9fb250fafb763e67552d2400
3
+ metadata.gz: 1f6fcbc8cf8afaf0cf827cdfbd109435935adb52
4
+ data.tar.gz: 1cfe704eb579fb86e97e7c99ac44555a28ddf490
5
5
  SHA512:
6
- metadata.gz: 7a79629f517c0e2b2a895780d2043f6cb90dd22babd6482f53f22bf0000ac1777de269e955b72381779bc5abdae41d7232afd5618a5a9e80839bc8189aa1dbdd
7
- data.tar.gz: 04944fbfe2ecc152ebeaec0a15834df3a0dc8b4f675f470c7faed8eee5c4d19308c38efdeb4cd95592a6f01ff9d8b853c097ccfb84bfd9726f0b7946613cf526
6
+ metadata.gz: d840c314529c38da7df35390e6dcfd666b5c748ff9a390c289caf6702080bd8f147da30199071ff69fe621400f48a5cbbc2baa7d6d8474abaf22ae1b7a714c31
7
+ data.tar.gz: 1191bd4b2b0c7e4668349260c5d571090b2d8cacdac03d38ce2257f8ceba83f7370f7863d0477ad1245bb7400420da0aefeaa36cd056d206b8dd44d3a25ec8b2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## [v1.0.2](https://github.com/lscspirit/app_config_loader/tree/v1.0.2) (2017-04-23)
4
+ [Full list of commits](https://github.com/lscspirit/app_config_loader/compare/v1.0.1...v1.0.2)
5
+
6
+ - properly raise ConfigKeyConflict exception in ConfigMap#deep_add
7
+
3
8
  ## [v1.0.1](https://github.com/lscspirit/app_config_loader/tree/v1.0.1) (2017-01-12)
4
9
  [Full list of commits](https://github.com/lscspirit/app_config_loader/compare/58ae3bea8d929ce97ac2985f4485d435bd6056c6...v1.0.1)
5
10
 
@@ -5,18 +5,14 @@ module AppConfigLoader
5
5
  end
6
6
 
7
7
  def add(entry, overwrite = false)
8
- begin
9
- deep_add(@key_map, entry.key_components) do |existing|
10
- if existing
11
- # only override the existing entry if 'force' is true or
12
- # the new entry has a higher specificity
13
- overwrite || entry.specificity >= existing.specificity ? entry : existing
14
- else
15
- entry
16
- end
8
+ deep_add(@key_map, entry.key_components) do |existing|
9
+ if existing
10
+ # only override the existing entry if 'force' is true or
11
+ # the new entry has a higher specificity
12
+ overwrite || entry.specificity >= existing.specificity ? entry : existing
13
+ else
14
+ entry
17
15
  end
18
- rescue => ex
19
- raise ConfigKeyConflict, "key conflict for '#{entry.key}': #{ex.message}"
20
16
  end
21
17
  end
22
18
 
@@ -47,15 +43,16 @@ module AppConfigLoader
47
43
  def deep_add(parent, keys, &block)
48
44
  current_key = keys[0].to_sym
49
45
 
46
+ val = parent[current_key]
47
+
50
48
  if keys.count == 1
51
- val = parent[current_key]
52
49
 
53
50
  #
54
51
  # the last key
55
52
  #
56
53
 
57
54
  # check if the key has child configuration
58
- raise "key '#{current_key}' has at least one child config" if val.is_a?(Hash)
55
+ raise ConfigKeyConflict, "key conflict: '#{current_key}' has at least one child config" if val.is_a?(Hash)
59
56
 
60
57
  # yield to the block to determine what value to assign to the key
61
58
  parent[current_key] = yield val
@@ -65,7 +62,7 @@ module AppConfigLoader
65
62
  #
66
63
 
67
64
  # check if the key already has a value assigned
68
- raise "key '#{current_key}' already has a value assigned" unless val.nil? || val.is_a?(Hash)
65
+ raise ConfigKeyConflict, "key conflict: '#{current_key}' already has a value assigned" unless val.nil? || val.is_a?(Hash)
69
66
 
70
67
  # go to the next level
71
68
  val = (parent[current_key] ||= {})
@@ -1,3 +1,3 @@
1
1
  module AppConfigLoader
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app_config_loader
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derrick Yeung
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-11 00:00:00.000000000 Z
11
+ date: 2017-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.10'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.10'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: faker
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: A easy way to define application configurations using YAML in your Rails
@@ -74,8 +74,8 @@ executables: []
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
- - .gitignore
78
- - .travis.yml
77
+ - ".gitignore"
78
+ - ".travis.yml"
79
79
  - CHANGELOG.md
80
80
  - Gemfile
81
81
  - LICENSE.txt
@@ -101,17 +101,17 @@ require_paths:
101
101
  - lib
102
102
  required_ruby_version: !ruby/object:Gem::Requirement
103
103
  requirements:
104
- - - '>='
104
+ - - ">="
105
105
  - !ruby/object:Gem::Version
106
106
  version: '0'
107
107
  required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - '>='
109
+ - - ">="
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
112
  requirements: []
113
113
  rubyforge_project:
114
- rubygems_version: 2.6.7
114
+ rubygems_version: 2.5.1
115
115
  signing_key:
116
116
  specification_version: 4
117
117
  summary: Application configuration using YAML