realize 1.0.0 → 1.1.0

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: d5725ecd097c45ce632cd82af3b5c03cd7f54dec0503c007ee28498a2ebe2f0e
4
- data.tar.gz: c6731e9b7f14b3c7109e7a680ba107702dc2c65336e5cea75194f6f61501e796
3
+ metadata.gz: 0f1004b6b97c8ebd485bac4fb9859ffd28511240f4a9943c73875664be35722c
4
+ data.tar.gz: 979d68bb86ecc8ba32251c2346a0183158686bf04fb9949f04646e7e16a6a03b
5
5
  SHA512:
6
- metadata.gz: 1dc9995383fa3a27c3414cd1549871724583c19a1dccbda403b6dc6224927711a4d3309a894ddb9ed0c94587a2d7d37ac870a1fbe9fcc45a017073db39570ce0
7
- data.tar.gz: 2cc2a27d5faa2aa2cd188c94051beaa1cf92acc2e499b1cf3762f667a0e4e27c2f9a750cfd687990cbdfcf52d86ee494278b4062af0ab091aa117b1ab7db035f
6
+ metadata.gz: f2398a44d581a5e8685ef9c29acbb140fbc2488cb7ffc6411317254325154e30b72b3828b96df5aa7e17f299a79c802f4ece1a50486c0ec62d20bdcb9bd5f073
7
+ data.tar.gz: 9b87926382b38afda00be7ab8055ab26eea572228489f0d0efd341dd0b709d11d1becafa3e925d79baa5c30bccd0fab30130c8792e646891c902fc6cb7a23aa9
@@ -1,3 +1,7 @@
1
+ # 1.1.0 (June 24th, 2020)
2
+
3
+ Addition of r/collection/at_index, r/collection/first, and r/collection/last
4
+
1
5
  # 1.0.0 (June 9th, 2020)
2
6
 
3
7
  Initial Release, includes 15 initial transformers.
data/README.md CHANGED
@@ -62,6 +62,9 @@ Here is a list of each built-in transformer, their options, and what their funct
62
62
 
63
63
  #### Collection-oriented Transformers
64
64
 
65
+ * **r/collection/at_index** [index]: Takes an array (or coerces value to an array) and returns the value at the given index position.
66
+ * **r/collection/first** []: Takes an array (or coerces value to an array) and returns the value at the first index position.
67
+ * **r/collection/last** []: Takes an array (or coerces value to an array) and returns the value at the last index position.
65
68
  * **r/collection/sort** [key, direction]: Takes an array (or coerces value to an array) and sort it either ascending or descending by some defined key's value.
66
69
 
67
70
  #### Filtering Transformers
@@ -83,12 +86,12 @@ Here is a list of each built-in transformer, their options, and what their funct
83
86
 
84
87
  #### Value-oriented Transformers
85
88
 
86
- * **r/logical/blank** []: Always return a blank string.
87
- * **r/logical/map** [values]: Do a lookup on the value using the `values` hash. If a value is found, then its corresponding value is returned. If it isn't then the input is returned.
88
- * **r/logical/null** []: Always returns null.
89
- * **r/logical/resolve** [key]: Dynamically resolves a value based on the record's key. It uses the [Objectable](https://github.com/bluemarblepayroll/objectable) library by default, which provides some goodies like dot-notation for nested objects and type-insensitivity (works for Ruby objects, hashes, structs, etc.)
90
- * **r/logical/static** [value]: Always returns a hard-coded value.
91
- * **r/logical/verbatim** []: Default transformer, simply echos back the input.
89
+ * **r/value/blank** []: Always return a blank string.
90
+ * **r/value/map** [values]: Do a lookup on the value using the `values` hash. If a value is found, then its corresponding value is returned. If it isn't then the input is returned.
91
+ * **r/value/null** []: Always returns null.
92
+ * **r/value/resolve** [key]: Dynamically resolves a value based on the record's key. It uses the [Objectable](https://github.com/bluemarblepayroll/objectable) library by default, which provides some goodies like dot-notation for nested objects and type-insensitivity (works for Ruby objects, hashes, structs, etc.)
93
+ * **r/value/static** [value]: Always returns a hard-coded value.
94
+ * **r/value/verbatim** []: Default transformer, simply echos back the input.
92
95
 
93
96
  ### Plugging in Transformers
94
97
 
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Realize
4
+ class Collection
5
+ # Transformer to get an item of a collection
6
+ class AtIndex
7
+ acts_as_hashable
8
+
9
+ attr_reader :index
10
+
11
+ def initialize(index:)
12
+ raise ArgumentError, 'index is required' if index.to_s.empty?
13
+
14
+ @index = index.to_i
15
+
16
+ freeze
17
+ end
18
+
19
+ def transform(_resolver, value, _time, _record)
20
+ value.is_a?(Array) ? value[index] : value
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Realize
4
+ class Collection
5
+ # Transformer to get the first item of a collection
6
+ class First
7
+ acts_as_hashable
8
+
9
+ def transform(resolver, value, time, record)
10
+ AtIndex.new(index: 0).transform(resolver, value, time, record)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Realize
4
+ class Collection
5
+ # Transformer to get the last item of a collection
6
+ class Last
7
+ acts_as_hashable
8
+
9
+ def transform(resolver, value, time, record)
10
+ AtIndex.new(index: -1).transform(resolver, value, time, record)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'collection/at_index'
4
+ require_relative 'collection/first'
5
+ require_relative 'collection/last'
3
6
  require_relative 'collection/sort'
4
7
  require_relative 'filter/by_key_record_value'
5
8
  require_relative 'filter/by_key_value'
@@ -25,6 +28,9 @@ module Realize
25
28
  acts_as_hashable_factory
26
29
 
27
30
  register '', Value::Verbatim
31
+ register 'r/collection/at_index', Collection::AtIndex
32
+ register 'r/collection/first', Collection::First
33
+ register 'r/collection/last', Collection::Last
28
34
  register 'r/collection/sort', Collection::Sort
29
35
  register 'r/filter/by_key_record_value', Filter::ByKeyRecordValue
30
36
  register 'r/filter/by_key_value', Filter::ByKeyValue
@@ -8,5 +8,5 @@
8
8
  #
9
9
 
10
10
  module Realize
11
- VERSION = '1.0.0'
11
+ VERSION = '1.1.0'
12
12
  end
@@ -11,8 +11,8 @@ Gem::Specification.new do |s|
11
11
  Derive and transform a value using a configuration-first pipeline.
12
12
  DESCRIPTION
13
13
 
14
- s.authors = ['Matthew Ruggio']
15
- s.email = ['mruggio@bluemarblepayroll.com']
14
+ s.authors = ['Matthew Ruggio', 'Dan Dewar']
15
+ s.email = ['mruggio@bluemarblepayroll.com', 'ddewar@bluemarblepayroll.com']
16
16
  s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
17
  s.bindir = 'exe'
18
18
  s.executables = []
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: realize
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Ruggio
8
+ - Dan Dewar
8
9
  autorequire:
9
10
  bindir: exe
10
11
  cert_chain: []
11
- date: 2020-06-09 00:00:00.000000000 Z
12
+ date: 2020-06-24 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: acts_as_hashable
@@ -145,6 +146,7 @@ dependencies:
145
146
  description: " Derive and transform a value using a configuration-first pipeline.\n"
146
147
  email:
147
148
  - mruggio@bluemarblepayroll.com
149
+ - ddewar@bluemarblepayroll.com
148
150
  executables: []
149
151
  extensions: []
150
152
  extra_rdoc_files: []
@@ -165,6 +167,9 @@ files:
165
167
  - exe/.gitkeep
166
168
  - lib/realize.rb
167
169
  - lib/realize/arrays.rb
170
+ - lib/realize/collection/at_index.rb
171
+ - lib/realize/collection/first.rb
172
+ - lib/realize/collection/last.rb
168
173
  - lib/realize/collection/sort.rb
169
174
  - lib/realize/collection/sort/direction.rb
170
175
  - lib/realize/filter/by_key_record_value.rb