remap 2.2.51 → 2.2.53

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: 9d9b65b616274770efbfd7e0cbc0a1267dad1f362c8b00031b389467099fd7dd
4
- data.tar.gz: ce414f535c4a5d045b7cda3b3e265ddca8ac100ed2937a55d5e812a033e4beea
3
+ metadata.gz: 8321a7ce3b3551b961e63d2356ae3838479cdcdd4f2fb51f8c4f67b5887f12b3
4
+ data.tar.gz: 68217f949d43548ea387ce2e9884197d7daf36de134fac99a4f2b74b65cfc2cf
5
5
  SHA512:
6
- metadata.gz: be33c29fca4e449ce50e40d25ed31153ac076c6ab4fdbeb56ec911f5e6b66a2502b496899a655619bbd230e303320e5b279730e4e412f3b3ef7f720fd1a709b1
7
- data.tar.gz: 69bdec20f5147b7a9def5404c3a00c73a8a15f247d201189d96ee9b5c345795b9fc41ea3b65ba2244154ab0ade712b8b0aeee7d10d3ddf87737e402b761c9c88
6
+ metadata.gz: f326c30a0f54ad76625f0a40112a92fee50677bfc72feb86189d14e820cb559d845da3876f025a532cb6c4d6f9b80d9f12a3bd1a3243a29f71078e7c256fb659
7
+ data.tar.gz: d51927615c82c036755ee5e4840baa001d3d46fdfa4dc607b5c38c59189ce9efe95d3513a7dce0b9965127d1327f83d3dd4cc4d2c49a21446c3ed241e91e6c21
@@ -5,6 +5,21 @@ module Remap
5
5
  using Extensions::Enumerable
6
6
  using State::Extension
7
7
 
8
+ # TODO: Move & Test
9
+ module Dispatch
10
+ refine Static::Option do
11
+ def call(...)
12
+ super.value
13
+ end
14
+ end
15
+
16
+ refine Object do
17
+ def call(_)
18
+ self
19
+ end
20
+ end
21
+ end
22
+
8
23
  # Sets the value to a given path
9
24
  #
10
25
  # @example Maps "A" to { a: { b: { c: "A" } } }
@@ -13,12 +28,18 @@ module Remap
13
28
  #
14
29
  # result.fetch(:value) # => { a: { b: { c: "A" } } }
15
30
  class Output < Unit
31
+ using Dispatch
32
+
16
33
  attribute :selectors, [Types::Key]
17
34
 
18
35
  # @return [State]
19
36
  def call(state)
37
+ mapped = selectors.map do |selector|
38
+ selector.call(state)
39
+ end
40
+
20
41
  state.fmap do |value|
21
- selectors.hide(value)
42
+ mapped.hide(value)
22
43
  end
23
44
  end
24
45
  end
@@ -109,27 +109,27 @@ module Remap
109
109
  # @return [State]
110
110
  def map(&block)
111
111
  result = case self
112
- in { value: Array => array }
113
- array.each_with_index.each_with_object([]) do |(value, index), array|
114
- s1 = block[set(value, index: index)]
115
-
116
- if s1.key?(:value)
117
- array << s1[:value]
118
- end
119
- end
120
- in { value: Hash => hash }
121
- hash.each_with_object({}) do |(key, value), acc|
122
- s1 = block[set(value, key: key)]
123
-
124
- if s1.key?(:value)
125
- acc[key] = s1[:value]
126
- end
127
- end
128
- in { value: }
129
- fatal!("Expected an enumerable got %s", value.class)
130
- else
131
- return self
132
- end
112
+ in { value: Array => array }
113
+ array.each_with_index.each_with_object([]) do |(value, index), array|
114
+ s1 = block[set(value, index: index)]
115
+
116
+ if s1.key?(:value)
117
+ array << s1[:value]
118
+ end
119
+ end
120
+ in { value: Hash => hash }
121
+ hash.each_with_object({}) do |(key, value), acc|
122
+ s1 = block[set(value, key: key)]
123
+
124
+ if s1.key?(:value)
125
+ acc[key] = s1[:value]
126
+ end
127
+ end
128
+ in { value: }
129
+ fatal!("Expected an enumerable got %s", value.class)
130
+ else
131
+ return self
132
+ end
133
133
 
134
134
  set(result)
135
135
  end
@@ -402,27 +402,23 @@ module Remap
402
402
  # @return [Failure]
403
403
  def failure(reason = Undefined)
404
404
  failures = case [path, reason]
405
- in [_, Undefined]
406
- return Failure.new(failures: notices)
407
- in [_, Notice => notice]
408
- [notice]
409
- in [path, Array => reasons]
410
- reasons.map do |inner_reason|
411
- Notice.call(path: path, reason: inner_reason, **only(:value))
412
- end
413
- in [path, String => reason]
414
- [Notice.call(path: path, reason: reason, **only(:value))]
415
- in [path, Hash => errors]
416
- errors.paths.flat_map do |sufix|
417
- Array.wrap(errors.dig(*sufix)).map do |inner_reason|
418
- Notice.call(
419
- reason: inner_reason,
420
- path: path + sufix,
421
- **only(:value)
422
- )
423
- end
424
- end
425
- end
405
+ in [_, Undefined]
406
+ return Failure.new(failures: notices)
407
+ in [_, Notice => notice]
408
+ [notice]
409
+ in [path, Array => reasons]
410
+ reasons.map do |inner_reason|
411
+ Notice.call(path: path, reason: inner_reason, **only(:value))
412
+ end
413
+ in [path, String => reason]
414
+ [Notice.call(path: path, reason: reason, **only(:value))]
415
+ in [path, Hash => errors]
416
+ errors.paths.flat_map do |sufix|
417
+ Array.wrap(errors.dig(*sufix)).map do |inner_reason|
418
+ Notice.call(reason: inner_reason, path: path + sufix, **only(:value))
419
+ end
420
+ end
421
+ end
426
422
 
427
423
  Failure.new(failures: failures, notices: notices)
428
424
  end
data/lib/remap/state.rb CHANGED
@@ -3,7 +3,6 @@
3
3
  require "dry/schema"
4
4
  require "dry/validation"
5
5
  require "dry/core/constants"
6
- require "factory_bot"
7
6
  require "dry/logic"
8
7
  require "dry/logic/operations"
9
8
  require "dry/logic/predicates"
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remap
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.51
4
+ version: 2.2.53
5
5
  platform: ruby
6
6
  authors:
7
7
  - Linus Oleander
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-24 00:00:00.000000000 Z
11
+ date: 2022-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 6.1.4.1
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '8.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: 6.1.4.1
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '8.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: dry-core
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -239,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
239
245
  - !ruby/object:Gem::Version
240
246
  version: '0'
241
247
  requirements: []
242
- rubygems_version: 3.2.32
248
+ rubygems_version: 3.3.26
243
249
  signing_key:
244
250
  specification_version: 4
245
251
  summary: An expressive and feature-complete data mapper with intuitive syntax thanks