remap 2.2.35 → 2.2.39

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
  SHA256:
3
- metadata.gz: 38765a313ed6b492d7f898519fe1303dcad63ec19e266b2192e94a9f96813a87
4
- data.tar.gz: 8a1fee97a5ea6a1f9d8e8d296e71e5b5dd1881580683870e9824f40158eb0e97
3
+ metadata.gz: 63e86ddbef0fd288ba558768cd947639c566f4db3789b19163c0ead17782635f
4
+ data.tar.gz: 2e3359e5d2ca7f78e1c2540c9289d489d132be91456493eaf2e4c6f8542b9b4a
5
5
  SHA512:
6
- metadata.gz: 3542fc58722ff987b0307c83e339659af0bfcd358dabfbbec338c582f66cb78d10c0e325ca4ba319bb925001c14cc8f6174e189a7435abece4aff0e9276b716c
7
- data.tar.gz: 1b82a610fd18d8583ff6f26098e733cbea67a92381af7bcd20cc0a15e41fc025e3a8642678fdd40a3e8224ecbd2abd5d0b6c29f19163302224bf670e452d000b
6
+ metadata.gz: 8f2f4134ae97e0e00e9e346e271a2d07e4ded2e4e4e1c8b2a80efdbfd0a41d39c615bee75e61c582d9fa5cda514f74fb164a197f136ea7b1bf170b618b2b383d
7
+ data.tar.gz: e88fe7b9c0c8aef4a03f630315b9813ec1bbe5cda5851cadda400b9ea110903cb62732ccf6b89e3b0d35aebe982280c34d49558259e1b40de2d385d599e0565c
@@ -176,12 +176,12 @@ module Remap
176
176
  # output.fetch(:value) # => { car: "Volvo" }
177
177
  #
178
178
  # @return [Rule::Embed]
179
- def embed(mapper)
179
+ def embed(mapper, backtrace: caller)
180
180
  if block_given?
181
181
  raise ArgumentError, "#embed does not take a block"
182
182
  end
183
183
 
184
- embeding = rule.add do |state, &error|
184
+ embeding = rule(backtrace: backtrace).add do |state, &error|
185
185
  mapper.call!(state.set(mapper: mapper)) do |failure|
186
186
  next error[failure]
187
187
  end.except(:mapper, :scope)
@@ -225,12 +225,12 @@ module Remap
225
225
  # @raise [ArgumentError]
226
226
  # if no path given
227
227
  # if path is not a Symbol or Array<Symbol>
228
- def set(*path, to:)
228
+ def set(*path, to:, backtrace: caller)
229
229
  if block_given?
230
230
  raise ArgumentError, "#set does not take a block"
231
231
  end
232
232
 
233
- add rule(to: path).add { to.call(_1) }
233
+ add rule(to: path, backtrace: backtrace).add { to.call(_1) }
234
234
  end
235
235
 
236
236
  # Maps to path from map with block in between
@@ -280,8 +280,8 @@ module Remap
280
280
  # @see #to
281
281
  #
282
282
  # @return [Rule::Map::Optional]
283
- def to?(*path, map: EMPTY_ARRAY, &block)
284
- add rule?(*map, to: path, &block)
283
+ def to?(*path, map: EMPTY_ARRAY, backtrace: caller, &block)
284
+ add rule?(*map, to: path, backtrace: backtrace, &block)
285
285
  end
286
286
 
287
287
  # Iterates over the input value, passes each value
@@ -308,12 +308,12 @@ module Remap
308
308
  #
309
309
  # @return [Rule::Each]]
310
310
  # @raise [ArgumentError] if no block given
311
- def each(&block)
311
+ def each(backtrace: caller, &block)
312
312
  unless block_given?
313
313
  raise ArgumentError, "#each requires a block"
314
314
  end
315
315
 
316
- add rule(all, &block)
316
+ add rule(all, backtrace: backtrace, &block)
317
317
  end
318
318
 
319
319
  # Wraps output in type
@@ -341,12 +341,12 @@ module Remap
341
341
  #
342
342
  # @return [Rule::Wrap]
343
343
  # @raise [ArgumentError] if type is not :array
344
- def wrap(type, &block)
344
+ def wrap(type, backtrace: caller, &block)
345
345
  unless block_given?
346
346
  raise ArgumentError, "#wrap requires a block"
347
347
  end
348
348
 
349
- add rule(&block).then { Array.wrap(_1) }
349
+ add rule(backtrace: backtrace, &block).then { Array.wrap(_1) }
350
350
  end
351
351
 
352
352
  # Selects all elements
@@ -394,12 +394,12 @@ module Remap
394
394
  # output.fetch(:value) # => { api_key: "<SECRET>" }
395
395
  #
396
396
  # @return [Rule::Static::Fixed]
397
- def value(value)
397
+ def value(value, backtrace: caller)
398
398
  if block_given?
399
399
  raise ArgumentError, "option selector does not take a block"
400
400
  end
401
401
 
402
- Static::Fixed.new(value: value)
402
+ Static::Fixed.new(value: value, backtrace: backtrace)
403
403
  end
404
404
 
405
405
  # Static option to be selected
@@ -25,8 +25,13 @@ module Remap
25
25
  end
26
26
 
27
27
  def traced(backtrace)
28
- tap { _1.set_backtrace(backtrace) }
28
+ e = Traced.new(notice: notice)
29
+ e.set_backtrace(backtrace)
30
+ e
29
31
  end
30
32
  end
33
+
34
+ class Traced < Error
35
+ end
31
36
  end
32
37
  end
@@ -23,11 +23,15 @@ module Remap
23
23
  return state.except(:value)
24
24
  end
25
25
 
26
- rules.map do |rule|
27
- rule.call(state) do |failure|
26
+ rules.reduce(state.except(:value)) do |s1, rule|
27
+ result = rule.call(state) do |failure|
28
28
  return error[failure]
29
29
  end
30
- end.reduce(&:combine)
30
+
31
+ s1.combine(result)
32
+ rescue Notice::Fatal => e
33
+ raise e.traced(rule.backtrace)
34
+ end
31
35
  end
32
36
  end
33
37
  end
@@ -41,7 +41,7 @@ module Remap
41
41
  end
42
42
 
43
43
  element = array.fetch(index) do
44
- s.ignore!("Index %s not found", index)
44
+ s.ignore!("Index not found")
45
45
  end
46
46
 
47
47
  state.set(element, index: index).then(&block)
@@ -132,7 +132,7 @@ module Remap
132
132
  list1 + list2
133
133
  in [:value, left, right]
134
134
  fatal!(
135
- "Could not merge [%p] (%s) with [%p] (%s)",
135
+ "Could not merge [%s] (%s) with [%s] (%s)",
136
136
  left.formatted,
137
137
  left.class,
138
138
  right.formatted,
@@ -26,11 +26,11 @@ module Remap
26
26
  #
27
27
  # @return [State]
28
28
  def call(state)
29
- state.set(state.options.fetch(name))
30
- rescue KeyError => e
31
- raise ArgumentError, e.exception("Option [%s] not found in input [%p]" % [
32
- name, state.options
33
- ])
29
+ value = state.options.fetch(name) do
30
+ raise ArgumentError, "Option [%s] not found" % [name], backtrace
31
+ end
32
+
33
+ state.set(value)
34
34
  end
35
35
  end
36
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remap
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.35
4
+ version: 2.2.39
5
5
  platform: ruby
6
6
  authors:
7
7
  - Linus Oleander
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-11 00:00:00.000000000 Z
11
+ date: 2021-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport