remap 2.1.15 → 2.1.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/remap/base.rb +3 -3
- data/lib/remap/contract.rb +2 -2
- data/lib/remap/extensions/enumerable.rb +1 -1
- data/lib/remap/extensions/hash.rb +1 -1
- data/lib/remap/extensions/object.rb +2 -2
- data/lib/remap/failure.rb +1 -1
- data/lib/remap/notice.rb +1 -1
- data/lib/remap/rule/map/required.rb +1 -1
- data/lib/remap/state/extension.rb +2 -2
- data/lib/remap/state.rb +9 -13
- data/lib/remap/types.rb +1 -1
- 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: a243cc530ffa8fca52cc84b20e3e5e5c89a369fa3022e76875b97c1b23f32424
|
4
|
+
data.tar.gz: 1b82bce8c377f1ee96e1e4ce90ff918697b57ce5b80ccd3d8084f157bfa2e71f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 810a6b0e590fa0a24e808dd6107d45452363404eeaffaa434b175e08a22f7fa3b5fc18eb11c4fa0095c608cdddbd516bf0aaa6431858c306e03bc13180797d4a
|
7
|
+
data.tar.gz: e23f0a726b628264ee62262f148cc1c24be7690985fec312c17f0407e1b70f1f5e3bc6907811b308b74eabf8fa091b0dfff5da52ad746d00a7669673b481305f
|
data/lib/remap/base.rb
CHANGED
@@ -110,7 +110,7 @@ module Remap
|
|
110
110
|
extend Operation
|
111
111
|
|
112
112
|
with_options instance_accessor: true do |scope|
|
113
|
-
scope.config_accessor(:contract) { Dry::Schema.
|
113
|
+
scope.config_accessor(:contract) { Dry::Schema.define {} }
|
114
114
|
scope.config_accessor(:constructor) { IDENTITY }
|
115
115
|
scope.config_accessor(:options) { EMPTY_ARRAY }
|
116
116
|
scope.config_accessor(:option) { EMPTY_HASH }
|
@@ -175,7 +175,7 @@ module Remap
|
|
175
175
|
#
|
176
176
|
# @return [void]
|
177
177
|
def self.rule(...)
|
178
|
-
self.rules = rules + [->
|
178
|
+
self.rules = rules + [-> { rule(...) }]
|
179
179
|
end
|
180
180
|
|
181
181
|
# Defines a required option for the mapper
|
@@ -212,7 +212,7 @@ module Remap
|
|
212
212
|
# @option method (:new) [Symbol]
|
213
213
|
# @option strategy (:argument) [:argument, :keywords, :none]
|
214
214
|
#
|
215
|
-
# @example A mapper, which
|
215
|
+
# @example A mapper, which maps a value at [:a] to [:b]
|
216
216
|
# class Mapper < Remap::Base
|
217
217
|
# define do
|
218
218
|
# map :a, to: :b
|
data/lib/remap/contract.rb
CHANGED
@@ -13,11 +13,11 @@ module Remap
|
|
13
13
|
def self.call(rules:, options:, contract:, attributes:)
|
14
14
|
Class.new(self) do
|
15
15
|
rules.each do |rule|
|
16
|
-
|
16
|
+
instance_exec(&rule)
|
17
17
|
end
|
18
18
|
|
19
19
|
options.each do |option|
|
20
|
-
|
20
|
+
instance_exec(&option)
|
21
21
|
end
|
22
22
|
|
23
23
|
schema(contract)
|
@@ -34,7 +34,7 @@ module Remap
|
|
34
34
|
return self if path.empty?
|
35
35
|
|
36
36
|
unless block_given?
|
37
|
-
get(*path, trace: trace) do
|
37
|
+
return get(*path, trace: trace) do
|
38
38
|
raise PathError, trace
|
39
39
|
end
|
40
40
|
end
|
@@ -43,7 +43,7 @@ module Remap
|
|
43
43
|
end
|
44
44
|
alias_method :fetch, :get
|
45
45
|
|
46
|
-
def
|
46
|
+
def formatted
|
47
47
|
self
|
48
48
|
end
|
49
49
|
end
|
data/lib/remap/failure.rb
CHANGED
data/lib/remap/notice.rb
CHANGED
@@ -88,7 +88,7 @@ module Remap
|
|
88
88
|
# @return [self]
|
89
89
|
def _(&block)
|
90
90
|
unless block
|
91
|
-
return _ { raise ArgumentError, "Input: #{self} output: #{_1.
|
91
|
+
return _ { raise ArgumentError, "Input: #{self} output: #{_1.formatted}" }
|
92
92
|
end
|
93
93
|
|
94
94
|
unless (result = Schema.call(self)).success?
|
@@ -117,7 +117,7 @@ module Remap
|
|
117
117
|
|
118
118
|
# @return [String]
|
119
119
|
def inspect
|
120
|
-
"#<State %s>" % compact_blank.
|
120
|
+
"#<State %s>" % compact_blank.formatted
|
121
121
|
end
|
122
122
|
|
123
123
|
# Merges {self} with {other} and returns a new state
|
data/lib/remap/state.rb
CHANGED
@@ -30,19 +30,15 @@ module Remap
|
|
30
30
|
#
|
31
31
|
# @return [Hash] A valid state
|
32
32
|
def self.call(value, mapper: Dummy, options: EMPTY_HASH)
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
}._
|
43
|
-
end
|
44
|
-
|
45
|
-
raise ArgumentError, "Input is a state: #{value}"
|
33
|
+
{
|
34
|
+
notices: EMPTY_ARRAY,
|
35
|
+
path: EMPTY_ARRAY,
|
36
|
+
options: options,
|
37
|
+
mapper: mapper,
|
38
|
+
values: value,
|
39
|
+
value: value,
|
40
|
+
input: value
|
41
|
+
}._
|
46
42
|
end
|
47
43
|
end
|
48
44
|
end
|
data/lib/remap/types.rb
CHANGED