remap 2.2.49 → 2.2.50

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: b08b87634002b0cae7bb2cd048e0ec99cfcec6769fdd583f9aabed3f350bdec4
4
- data.tar.gz: de61b4d83778f29f4580a41a4e6eda80f5817ade7fbda0dddd7a6192034270e9
3
+ metadata.gz: a036948beb3769bca586002c771569e54639a3a60314bac615a8f2dbb25a546b
4
+ data.tar.gz: 966315eb1929aa681d95d477e72a4545bdc435a4a4e3583d1cec875e8061d479
5
5
  SHA512:
6
- metadata.gz: e52d7bca5b4304ce6dd05fc7d868c49af4a0db0ccd9616a851c0ed0daa66425807f50baa6fbba9fcd4b1a8f5fcb177895c0b9bcb87fc3d1f34fee051c07fc172
7
- data.tar.gz: 100f753a963b91ae5b8eca6ef7c480b19704e848efab92de313ffbd7c9048daf9db30a1422b4a65e7029c905def26b0690dd12c7279f4dd23c0eb8b4784ae805
6
+ metadata.gz: f9afa516dd3d8248b714744598c847d04525f1d2d0e0f320128c6b785281b0a40e93d1b444cca6b4d1b6199bdb85dffa5fe4cda1c1d9ef97ec58f348a4994271
7
+ data.tar.gz: 72c2bfaaecc2553b3097f5b464cb03772314dab2127b5154d64b6e99e7e0c028ccba987c94acda788c7fa9229f48a626c895d558a6a974d8cbf95ae16b2d7ea5
@@ -15,28 +15,28 @@ module Remap
15
15
  # end
16
16
  # result.fetch(:value) # => [Hash, Hash]
17
17
  class All < Concrete
18
- requirement Types::Enumerable
19
-
20
18
  # Iterates over state and passes each value to block
21
19
  #
22
- # @param outer_state [State<Enumerable<T>>]
20
+ # @param state [State<Enumerable<T>>]
23
21
  #
24
22
  # @yieldparam [State<T>]
25
23
  # @yieldreturn [State<U>]
26
24
  #
27
25
  # @return [State<U>]
28
- def call(outer_state, &block)
26
+ def call(state, &block)
29
27
  unless block
30
28
  raise ArgumentError, "All selector requires an iteration block"
31
29
  end
32
30
 
33
- outer_state.bind(quantifier: "*") do |enum, state|
34
- requirement[enum] do
35
- state.fatal!("Expected enumerable")
36
- end
31
+ value = state.fetch(:value) do
32
+ return state
33
+ end
37
34
 
38
- state.map(&block)
35
+ unless value.is_a?(Enumerable)
36
+ state.fatal!("Not an enumerator")
39
37
  end
38
+
39
+ state.map(&block)
40
40
  end
41
41
  end
42
42
  end
@@ -20,8 +20,6 @@ module Remap
20
20
  # @return [Integer]
21
21
  attribute :index, Integer
22
22
 
23
- requirement Types::Array
24
-
25
23
  # Selects the {#index}th element from state and passes it to block
26
24
  #
27
25
  # @param state [State<Array<T>>]
@@ -35,17 +33,17 @@ module Remap
35
33
  raise ArgumentError, "The index selector requires an iteration block"
36
34
  end
37
35
 
38
- state.bind(index: index) do |array, s|
39
- requirement[array] do
40
- s.fatal!("Expected an array")
41
- end
36
+ array = state.fetch(:value) { return state }
42
37
 
43
- element = array.fetch(index) do
44
- s.ignore!("Index not found")
45
- end
38
+ unless array.is_a?(Array)
39
+ state.fatal!("Expected an array got %s", array.class)
40
+ end
46
41
 
47
- state.set(element, index: index).then(&block)
42
+ value = array.fetch(index) do
43
+ state.ignore!("Index [%s] (%s) not found", index, index.class)
48
44
  end
45
+
46
+ state.set(value, index: index).then(&block)
49
47
  end
50
48
  end
51
49
  end
@@ -17,8 +17,6 @@ module Remap
17
17
  # @return [#hash
18
18
  attribute :key, Types::Key
19
19
 
20
- requirement Types::Hash
21
-
22
20
  # Selects {#key} from state and passes it to block
23
21
  #
24
22
  # @param state [State<Hash<K, V>>]
@@ -32,17 +30,17 @@ module Remap
32
30
  raise ArgumentError, "The key selector requires an iteration block"
33
31
  end
34
32
 
35
- state.bind(key: key) do |hash, s|
36
- requirement[hash] do
37
- s.fatal!("Expected hash")
38
- end
33
+ hash = state.fetch(:value) { return state }
39
34
 
40
- value = hash.fetch(key) do
41
- s.ignore!("Key not found")
42
- end
35
+ unless hash.is_a?(Hash)
36
+ state.fatal!("Expected hash got %s", hash.class)
37
+ end
43
38
 
44
- state.set(value, key: key).then(&block)
39
+ value = hash.fetch(key) do
40
+ state.ignore!("Key [%s] (%s) not found", key, key.class)
45
41
  end
42
+
43
+ state.set(value, key: key).then(&block)
46
44
  end
47
45
  end
48
46
  end
@@ -4,9 +4,6 @@ module Remap
4
4
  # Defines how a path element, or selector
5
5
  # Specifies how a value is extracted from a state
6
6
  class Selector < Dry::Interface
7
- defines :requirement, type: Types::Any.constrained(type: Dry::Types::Type)
8
- requirement Types::Any
9
-
10
7
  # Selects value from state, package it as a state and passes it to block
11
8
  #
12
9
  # @param state [State]
@@ -20,12 +17,5 @@ module Remap
20
17
  def call(state)
21
18
  raise NotImplementedError, "#{self.class}#call not implemented"
22
19
  end
23
-
24
- private
25
-
26
- # @return [Dry::Types::Type]
27
- def requirement
28
- self.class.requirement
29
- end
30
20
  end
31
21
  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.2.49
4
+ version: 2.2.50
5
5
  platform: ruby
6
6
  authors:
7
7
  - Linus Oleander