remap 2.1.15 → 2.1.22

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e3439c23b054b2470688ec55cedb4dc0d7c0f77544c45f8f47c82b5d8d9b954a
4
- data.tar.gz: 515558fee642db02bd30e5194846a4486f6b59c67830c46581b9b3d3c529532e
3
+ metadata.gz: a243cc530ffa8fca52cc84b20e3e5e5c89a369fa3022e76875b97c1b23f32424
4
+ data.tar.gz: 1b82bce8c377f1ee96e1e4ce90ff918697b57ce5b80ccd3d8084f157bfa2e71f
5
5
  SHA512:
6
- metadata.gz: 599b8f2de0d62e5d4ab8ded2d303243fe11292f0cc621b7cdf66bb9e70ac712bb3fe4811cd926e9929a06f110445e283b2b8c3134a68cec5c810c53f572f720c
7
- data.tar.gz: 6cf4704750445ac8dfdac08cfe2beec2bff5ac34db4c61557f9239b49857c3a1423978d6cc38342917753d48b4edeeff397d012c8b91d32a3ee49ec96ab62fa4
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.JSON {} }
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 + [-> * { rule(...) }]
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 mapps a value at [:a] to [:b]
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
@@ -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
- class_eval(&rule)
16
+ instance_exec(&rule)
17
17
  end
18
18
 
19
19
  options.each do |option|
20
- class_eval(&option)
20
+ instance_exec(&option)
21
21
  end
22
22
 
23
23
  schema(contract)
@@ -34,7 +34,7 @@ module Remap
34
34
  key = path.first
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 + [key]
39
39
  end
40
40
  end
@@ -4,7 +4,7 @@ module Remap
4
4
  module Extensions
5
5
  module Hash
6
6
  refine ::Hash do
7
- def formated
7
+ def formatted
8
8
  JSON.neat_generate(self, sort: true, wrap: 40, aligned: true, around_colon: 1)
9
9
  end
10
10
  end
@@ -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 formated
46
+ def formatted
47
47
  self
48
48
  end
49
49
  end
data/lib/remap/failure.rb CHANGED
@@ -30,7 +30,7 @@ module Remap
30
30
  end
31
31
 
32
32
  def exception
33
- Error.new(attributes.formated)
33
+ Error.new(attributes.formatted)
34
34
  end
35
35
  end
36
36
  end
data/lib/remap/notice.rb CHANGED
@@ -15,7 +15,7 @@ module Remap
15
15
  end
16
16
 
17
17
  def inspect
18
- "#<%s %s>" % [self.class, to_hash.formated]
18
+ "#<%s %s>" % [self.class, to_hash.formatted]
19
19
  end
20
20
  alias to_s inspect
21
21
 
@@ -25,7 +25,7 @@ module Remap
25
25
  # })
26
26
  #
27
27
  # output = map.call(state) do |failure|
28
- # raise failure.exeception
28
+ # # ...
29
29
  # end
30
30
  #
31
31
  # output.fetch(:value) # => { nickname: "John" }
@@ -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.formated}" }
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.formated
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
- value._ do
34
- return {
35
- notices: EMPTY_ARRAY,
36
- path: EMPTY_ARRAY,
37
- options: options,
38
- mapper: mapper,
39
- values: value,
40
- value: value,
41
- input: value
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
@@ -26,7 +26,7 @@ module Remap
26
26
 
27
27
  next input if result.success?
28
28
 
29
- error[result.errors.to_h.formated]
29
+ error[result.errors.to_h.formatted]
30
30
  end
31
31
  end
32
32
  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.1.15
4
+ version: 2.1.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Linus Oleander