simplygenius-atmos 0.9.1 → 0.9.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
  SHA256:
3
- metadata.gz: c9f69449d48427430bc31762edb6359ac810e1fc32cf94d8ce051df7a6cb92b4
4
- data.tar.gz: 1dcb2ed97a319a93f5f87462c1553c898132f23f04dc90cf43807a87cc196ae3
3
+ metadata.gz: e52d0f9fe95219722359232e6a8895b0cdbf23f99fbeda7ad8a48fdfe8a21397
4
+ data.tar.gz: bb3c2e1d01fd2071ecc41e10b7622cb320e10dcd65ee90d254cc68465ee923db
5
5
  SHA512:
6
- metadata.gz: ef543813c52188072ddf10a179174fb6aee0b19fbcc6787fe0d10c928875481606554b18b43d782724624f1f3d61ee8d500dd9bb89cb1ac21bb3d61663541933
7
- data.tar.gz: 9a020c0a2b66a38e0a2f2145e03fdedede9792c18c83906c1b7191de1c7affa06d58e2fba573ebf751db58dbacea0be9d9b0abd26593cdf40f5dad82a2ca43b3
6
+ metadata.gz: 0da4f8dc5d90d23b6f5f7bbc348c4b5c1a431924e7763d369a5bbfd3528bae260a7e627294ad9aebc2e67e88cc3f7a5843a5b269b3c90fba88d7af37cf981bf5
7
+ data.tar.gz: c8e92569daec346d3c9e2a963374fcefd9e04c23a3a6d298fc9b3474871e8edc2f899c0903a5bc19a032993ec53588d4683e2c08ad3c8471d1f8b45a64eed1fc
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ 0.9.2 (12/01/2018)
2
+ ------------------
3
+
4
+ * add more useful display of type mismatches during config merges [b751a82](https://github.com/simplygenius/atmos/commit/b751a82)
5
+ * ensure all config files are hash like [5ad14fb](https://github.com/simplygenius/atmos/commit/5ad14fb)
6
+
1
7
  0.9.1 (11/30/2018)
2
8
  ------------------
3
9
 
@@ -104,40 +104,48 @@ module SimplyGenius
104
104
 
105
105
  INTERP_PATTERN = /(\#\{([^\}]+)\})/
106
106
 
107
- def config_merge(lhs, rhs)
107
+ def config_merge(lhs, rhs, debug_state=[])
108
108
  result = nil
109
109
 
110
110
  return rhs if lhs.nil?
111
111
  return lhs if rhs.nil?
112
112
 
113
113
  # Warn if user fat fingered config
114
- unless lhs.is_a?(rhs.class) || rhs.is_a?(lhs.class)
115
- logger.warn("Different types in deep merge: #{lhs.class}, #{rhs.class}")
116
- end
114
+ if lhs.is_a?(rhs.class) || rhs.is_a?(lhs.class)
117
115
 
118
- case rhs
119
- when Hash
120
- result = lhs.deep_dup
116
+ case rhs
117
+ when Hash
118
+ result = lhs.deep_dup
121
119
 
122
- lhs.each do |k, v|
123
- if k =~ /^\^(.*)/
124
- key = k.is_a?(Symbol) ? $1.to_sym : $1
125
- result[key] = result.delete(k)
120
+ lhs.each do |k, v|
121
+ if k =~ /^\^(.*)/
122
+ key = k.is_a?(Symbol) ? $1.to_sym : $1
123
+ result[key] = result.delete(k)
124
+ end
126
125
  end
127
- end
128
126
 
129
- rhs.each do |k, v|
130
- if k =~ /^\^(.*)/
131
- key = k.is_a?(Symbol) ? $1.to_sym : $1
132
- result[key] = v
133
- else
134
- result[k] = config_merge(result[k], v)
127
+ rhs.each do |k, v|
128
+ if k =~ /^\^(.*)/
129
+ key = k.is_a?(Symbol) ? $1.to_sym : $1
130
+ result[key] = v
131
+ else
132
+ result[k] = config_merge(result[k], v, debug_state + [k])
133
+ end
135
134
  end
135
+ when Enumerable
136
+ result = lhs + rhs
137
+ else
138
+ result = rhs
136
139
  end
137
- when Enumerable
138
- result = lhs + rhs
140
+
139
141
  else
142
+
143
+ logger.warn("Type mismatch while merging in: #{debug_state.delete_at(0)}")
144
+ logger.warn("Deep merge path: #{debug_state.join(" -> ")}")
145
+ logger.warn("Deep merge LHS (#{lhs.class}): #{lhs.inspect}")
146
+ logger.warn("Deep merge RHS (#{rhs.class}): #{rhs.inspect}")
140
147
  result = rhs
148
+
141
149
  end
142
150
 
143
151
  return result
@@ -158,11 +166,11 @@ module SimplyGenius
158
166
  Dir[pattern].each do |f|
159
167
  logger.debug("Loading atmos config file: #{f}")
160
168
  data = YAML.load_file(f)
161
- if data == false
162
- logger.debug("Skipping empty config file: #{f}")
169
+ if ! data.is_a?(Hash)
170
+ logger.debug("Skipping non-hash config file: #{f}")
163
171
  else
164
172
  h = SettingsHash.new(data)
165
- config = config_merge(config, h)
173
+ config = config_merge(config, h, [f])
166
174
  @included_configs << f
167
175
  end
168
176
  end
@@ -177,18 +185,18 @@ module SimplyGenius
177
185
  if File.exist?(submap_file)
178
186
  logger.debug("Loading atmos #{group} config file: #{submap_file}")
179
187
  data = YAML.load_file(submap_file)
180
- if data == false
181
- logger.debug("Skipping empty config file: #{submap_file}")
188
+ if ! data.is_a?(Hash)
189
+ logger.debug("Skipping non-hash config file: #{submap_file}")
182
190
  else
183
191
  h = SettingsHash.new({group => {name => data}})
184
- config = config_merge(config, h)
192
+ config = config_merge(config, h, [submap_file])
185
193
  @included_configs << submap_file
186
194
  end
187
195
  end
188
196
 
189
197
  begin
190
198
  submap = config.deep_fetch(group, name)
191
- config = config_merge(config, submap)
199
+ config = config_merge(config, submap, ["#{submap_file} submap(#{group}.#{name})"])
192
200
  rescue
193
201
  logger.debug("No #{group} config found for '#{name}'")
194
202
  end
@@ -206,7 +214,9 @@ module SimplyGenius
206
214
  @full_config = SettingsHash.new
207
215
  else
208
216
  logger.debug("Loading atmos config file #{config_file}")
209
- @full_config = SettingsHash.new(YAML.load_file(config_file))
217
+ data = YAML.load_file(config_file)
218
+ raise ArgumentError.new("Invalid main config file (not hash-like): #{config_file}") if ! data.is_a?(Hash)
219
+ @full_config = SettingsHash.new(data)
210
220
  @included_configs << config_file
211
221
  end
212
222
 
@@ -222,7 +232,7 @@ module SimplyGenius
222
232
  atmos_env: atmos_env,
223
233
  atmos_working_group: working_group,
224
234
  atmos_version: VERSION
225
- })
235
+ }, ["builtins"])
226
236
  expand(conf, conf)
227
237
  end
228
238
  end
@@ -1,5 +1,5 @@
1
1
  module SimplyGenius
2
2
  module Atmos
3
- VERSION = "0.9.1"
3
+ VERSION = "0.9.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplygenius-atmos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Conway
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-30 00:00:00.000000000 Z
11
+ date: 2018-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler