remap 2.2.41 → 2.2.42
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 +4 -4
- data/lib/remap/base.rb +2 -26
- data/lib/remap/mapper/binary.rb +1 -1
- data/lib/remap/mapper/support/api.rb +32 -0
- data/lib/remap.rb +1 -0
- metadata +2 -2
- data/lib/remap/operation.rb +0 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 791eca1356feec6a254c824130b798026851d4f0e56207b32144ba36f64d06a5
|
4
|
+
data.tar.gz: f7908a2f3dd0d4847860e342d4f11fa298ba5f9689bf8293d585122993ba40cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7eaed51a433437e884ea6af6485ad81752bfb5c7c388e678794c4e17447311b23aaa32d529451fbb70080617b9654f227fa7ac810d3dbff8e7c9c3e403f8de52
|
7
|
+
data.tar.gz: 3e14bdd50fa6e3ff3ad77589b969b294161a5878c007b9adba387614c3bcd86300e89ae72d9ea0252739269900757747294b7b89b8e0d2b6ad0ae162d363bd47
|
data/lib/remap/base.rb
CHANGED
@@ -106,9 +106,10 @@ module Remap
|
|
106
106
|
class Base < Mapper
|
107
107
|
include ActiveSupport::Configurable
|
108
108
|
include Dry::Core::Constants
|
109
|
-
|
110
109
|
include Catchable
|
111
110
|
|
111
|
+
extend Mapper::API
|
112
|
+
|
112
113
|
using State::Extension
|
113
114
|
|
114
115
|
with_options instance_accessor: true do |scope|
|
@@ -122,31 +123,6 @@ module Remap
|
|
122
123
|
|
123
124
|
schema schema.strict(false)
|
124
125
|
|
125
|
-
# extend Operation
|
126
|
-
|
127
|
-
def self.call(input, backtrace: caller, **options, &error)
|
128
|
-
unless block_given?
|
129
|
-
return call(input, **options) do |failure|
|
130
|
-
raise failure.exception(backtrace)
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
s0 = State.call(input, options: options, mapper: self)._
|
135
|
-
|
136
|
-
s1 = call!(s0) do |failure|
|
137
|
-
return error[failure]
|
138
|
-
end
|
139
|
-
|
140
|
-
case s1
|
141
|
-
in { value: value }
|
142
|
-
value
|
143
|
-
in { notices: [] }
|
144
|
-
error[s1.failure("No data could be mapped")]
|
145
|
-
in { notices: }
|
146
|
-
error[Failure.new(failures: notices)]
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
126
|
# Defines a schema for the mapper
|
151
127
|
# If the schema fail, the mapper will fail
|
152
128
|
#
|
data/lib/remap/mapper/binary.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Remap
|
4
|
+
class Mapper
|
5
|
+
using State::Extension
|
6
|
+
|
7
|
+
module API
|
8
|
+
def call(input, backtrace: caller, **options, &error)
|
9
|
+
unless block_given?
|
10
|
+
return call(input, **options) do |failure|
|
11
|
+
raise failure.exception(backtrace)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
s0 = State.call(input, options: options, mapper: self)._
|
16
|
+
|
17
|
+
s1 = call!(s0) do |failure|
|
18
|
+
return error[failure]
|
19
|
+
end
|
20
|
+
|
21
|
+
case s1
|
22
|
+
in { value: value }
|
23
|
+
value
|
24
|
+
in { notices: [] }
|
25
|
+
error[s1.failure("No data could be mapped")]
|
26
|
+
in { notices: }
|
27
|
+
error[Failure.new(failures: notices)]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/remap.rb
CHANGED
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.
|
4
|
+
version: 2.2.42
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Linus Oleander
|
@@ -271,6 +271,7 @@ files:
|
|
271
271
|
- lib/remap/mapper/and.rb
|
272
272
|
- lib/remap/mapper/binary.rb
|
273
273
|
- lib/remap/mapper/or.rb
|
274
|
+
- lib/remap/mapper/support/api.rb
|
274
275
|
- lib/remap/mapper/support/operations.rb
|
275
276
|
- lib/remap/mapper/xor.rb
|
276
277
|
- lib/remap/nothing.rb
|
@@ -278,7 +279,6 @@ files:
|
|
278
279
|
- lib/remap/notice/error.rb
|
279
280
|
- lib/remap/notice/fatal.rb
|
280
281
|
- lib/remap/notice/ignore.rb
|
281
|
-
- lib/remap/operation.rb
|
282
282
|
- lib/remap/path.rb
|
283
283
|
- lib/remap/path/input.rb
|
284
284
|
- lib/remap/path/output.rb
|
data/lib/remap/operation.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Remap
|
4
|
-
using State::Extension
|
5
|
-
|
6
|
-
# Class interface for {Remap::Base} and instance interface for {Mapper}
|
7
|
-
module Operation
|
8
|
-
# Public interface for mappers
|
9
|
-
#
|
10
|
-
# @param input [Any] data to be mapped
|
11
|
-
# @param options [Hash] mapper options
|
12
|
-
#
|
13
|
-
# @yield [Failure]
|
14
|
-
# when a non-critical error occurs
|
15
|
-
# @yieldreturn T
|
16
|
-
#
|
17
|
-
# @return [Any, T]
|
18
|
-
# when request is a success
|
19
|
-
# @raise [Remap::Error]
|
20
|
-
# when a fatal error occurs
|
21
|
-
def call(input, backtrace: caller, **options, &error)
|
22
|
-
unless block_given?
|
23
|
-
return call(input, **options) do |failure|
|
24
|
-
raise failure.exception(backtrace)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
s0 = State.call(input, options: options, mapper: self)._
|
29
|
-
|
30
|
-
s1 = call!(s0) do |failure|
|
31
|
-
return error[failure]
|
32
|
-
end
|
33
|
-
|
34
|
-
case s1
|
35
|
-
in { value: value }
|
36
|
-
value
|
37
|
-
in { notices: [] }
|
38
|
-
error[s1.failure("No data could be mapped")]
|
39
|
-
in { notices: }
|
40
|
-
error[Failure.new(failures: notices)]
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|