remap 2.2.38 → 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: 8fdfe8ed64a781f1239e1738a2e71b99acc864e60508353fc7d22c848b128cbb
4
- data.tar.gz: 654613c35e8d8294a94f748ca170da5bd19199dc66ba33c8ec055333e1deaf98
3
+ metadata.gz: 63e86ddbef0fd288ba558768cd947639c566f4db3789b19163c0ead17782635f
4
+ data.tar.gz: 2e3359e5d2ca7f78e1c2540c9289d489d132be91456493eaf2e4c6f8542b9b4a
5
5
  SHA512:
6
- metadata.gz: a56c3113747f8efc8721bf3d2731c0292c4c54e6570969b72f774433be0f7c64874af9fbb448bfe146978cc39d31725cde491e3a682d684e5e28909fa7a3e3ca
7
- data.tar.gz: b753d26605bdca1201be84826f4c352b426c4b853c687cc997ba964786827305268c805d6c6e85ee15e284becee4a8deaec9998dda35ff1e3431f919abe903e9
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
@@ -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
@@ -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)
@@ -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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remap
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.38
4
+ version: 2.2.39
5
5
  platform: ruby
6
6
  authors:
7
7
  - Linus Oleander