remap 2.2.41 → 2.2.42

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: 5a8ee7751985c548b272cb12bb0b08b655f52de3143075afafd8578f9e604eba
4
- data.tar.gz: f333d2922e7d5ef7a6bd050eb2fc0261446097fdd17f2745eef1a3bc35eb96ee
3
+ metadata.gz: 791eca1356feec6a254c824130b798026851d4f0e56207b32144ba36f64d06a5
4
+ data.tar.gz: f7908a2f3dd0d4847860e342d4f11fa298ba5f9689bf8293d585122993ba40cc
5
5
  SHA512:
6
- metadata.gz: 69b98a323c17562a06d4b83f3455c2b1c7e6a482280f5afe283f0d9570411391bb2d0de353d96250436d8aa51ad8443f1a3e25805dde0d6baebbc5286d019a9e
7
- data.tar.gz: 86f03041d4cf3ef2ebd1c597269645ae83c55e5d3326077a9d55f51f3f0a47aea131523e9e314d635f34d60487dbba20350a28ffa3eca9b032f0aecd01bf006f
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
  #
@@ -4,7 +4,7 @@ module Remap
4
4
  class Mapper
5
5
  # @abstract
6
6
  class Binary < self
7
- include Operation
7
+ include API
8
8
 
9
9
  attribute :left, Types::Mapper
10
10
  attribute :right, Types::Mapper
@@ -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
@@ -19,6 +19,7 @@ module Remap
19
19
  loader = Zeitwerk::Loader.for_gem
20
20
  loader.collapse("#{__dir__}/remap/mapper/support")
21
21
  loader.setup
22
+ loader.inflector.inflect "api" => "API"
22
23
  loader.eager_load
23
24
 
24
25
  include ClassInterface
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.41
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
@@ -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