remap 2.2.36 → 2.2.40
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/remap/compiler.rb +12 -12
- data/lib/remap/notice/error.rb +6 -1
- data/lib/remap/rule/block.rb +7 -3
- data/lib/remap/rule/map/optional.rb +0 -11
- data/lib/remap/rule/map.rb +0 -24
- data/lib/remap/selector/index.rb +1 -1
- data/lib/remap/state/extension.rb +1 -1
- data/lib/remap/static/option.rb +5 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5237c926e4f9d2101746dedf0c6287cf81e1e757000f45ff80a346852474ca1c
|
4
|
+
data.tar.gz: 18e5bde7388e9cf14a518153f0d47271bf6d09ad9b09a6dd4da98a2a61169668
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f9b976bca1187592db2ae0370e8ef33064ace68e15353d55c8e1bf16ea3d4c30afdac56e487ce663dc0d12241329a4484e9ea72ec0b8700c93654678e70b465
|
7
|
+
data.tar.gz: d8b580437f7c42ab3578fdf14b8f902d27c084438668f8dfdc67f9fbc74a73e16b0712bca50450f62212650955b9f5f53a59edda15243acb130a0e77e9ee2417
|
data/lib/remap/compiler.rb
CHANGED
@@ -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
|
data/lib/remap/notice/error.rb
CHANGED
data/lib/remap/rule/block.rb
CHANGED
@@ -23,11 +23,15 @@ module Remap
|
|
23
23
|
return state.except(:value)
|
24
24
|
end
|
25
25
|
|
26
|
-
rules.
|
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
|
-
|
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
|
@@ -39,17 +39,6 @@ module Remap
|
|
39
39
|
rescue Notice::Ignore => e
|
40
40
|
e.undefined(state)
|
41
41
|
end
|
42
|
-
|
43
|
-
private
|
44
|
-
|
45
|
-
# Catches :ignore exceptions and re-package them as a state
|
46
|
-
#
|
47
|
-
# @param state [State]
|
48
|
-
#
|
49
|
-
# @return [State]
|
50
|
-
def ignore(state, &block)
|
51
|
-
state.set(notice: catch(:ignore, &block).traced(backtrace)).except(:value)
|
52
|
-
end
|
53
42
|
end
|
54
43
|
end
|
55
44
|
end
|
data/lib/remap/rule/map.rb
CHANGED
@@ -209,30 +209,6 @@ module Remap
|
|
209
209
|
end
|
210
210
|
end
|
211
211
|
end
|
212
|
-
|
213
|
-
# Catches :fatal and raises {Notice::Error}
|
214
|
-
#
|
215
|
-
# @param state [State]
|
216
|
-
# @param id (:fatal) [:fatal, :notice, :ignore]
|
217
|
-
#
|
218
|
-
# raise [Notice::Error]
|
219
|
-
def fatal(state, id: :fatal, &block)
|
220
|
-
raise catch(id, &block).traced(backtrace).exception
|
221
|
-
end
|
222
|
-
|
223
|
-
# Catches :notice exceptions and repackages them as a state
|
224
|
-
#
|
225
|
-
# @param state [State]
|
226
|
-
#
|
227
|
-
# @return [State]
|
228
|
-
def notice(state, &block)
|
229
|
-
state.set(notice: catch(:notice, &block).traced(backtrace)).except(:value)
|
230
|
-
end
|
231
|
-
|
232
|
-
# @abstract
|
233
|
-
def ignore(...)
|
234
|
-
raise NotImplementedError, "#{self.class}#ignore"
|
235
|
-
end
|
236
212
|
end
|
237
213
|
end
|
238
214
|
end
|
data/lib/remap/selector/index.rb
CHANGED
data/lib/remap/static/option.rb
CHANGED
@@ -26,11 +26,11 @@ module Remap
|
|
26
26
|
#
|
27
27
|
# @return [State]
|
28
28
|
def call(state)
|
29
|
-
state.
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|