realize 1.3.0 → 1.4.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: 0d7bccc32a2837daee77ec8bcdda00975744c90e0ac08f62f5dbfcaf338dfd91
4
- data.tar.gz: aa23c2077287abe225dc2c4b7aa3a2bec7a405bdfd4011ce375d7aed64ac5f56
3
+ metadata.gz: 65013db138b786888e85a76bb1532122e0faf8ef4d2eff4e5e287231cda4e999
4
+ data.tar.gz: dc4117f7fc4d2c2b39767e24006c6811ca4065621e984554aaa0004a5bf4a9e9
5
5
  SHA512:
6
- metadata.gz: e1201c0671253238b656904b713482db1b53b1f720c36821b87618fd6d0ace49314eda6773080ccb3ed27fca50d8cb68f822547d9d631ff8529f437e7babdba5
7
- data.tar.gz: aadc039cccfdcae68d14b7902e854e14078ea2a674d7c4e84cc2f16c2f1e54f6f1cc1568a408676b726b581a5f80004861d44f751a350eb340d1bd995f02d3fe
6
+ metadata.gz: c5a90f318c8958386a920fe5643ce5e9851bc5e513c6e31634b3a06abe3e8c00b6e0b4990fca235f5ec8c608743f576ac7a27810499d3454dddd01629f405408
7
+ data.tar.gz: 3d58041bd36ce2ec71254cf17c0b98c883e213e0d3679b8b915b3f0d633f83f9818eeaea53e7395a5104017ad183e220bc8ccf2ed647f60d45c384002a105951
@@ -1,3 +1,10 @@
1
+ # 1.4.0 (November 16th, 2020)
2
+
3
+ New Transformers:
4
+
5
+ * r/format/lowercase
6
+ * r/format/uppercase
7
+
1
8
  # 1.3.0 (November 4th, 2020)
2
9
 
3
10
  New Transformers:
data/README.md CHANGED
@@ -77,10 +77,12 @@ Here is a list of each built-in transformer, their options, and what their funct
77
77
  #### Format-oriented Transformers
78
78
 
79
79
  * **r/format/date** [input_format, output_format]: Parses the incoming value into a Time object using the configured input_format and outputs it as formatted by the configured output_format.
80
+ * **r/format/lowercase** []: Calls `#to_s.downcase` on the value so the returned value is guaranteed to be a lower-cased string.
80
81
  * **r/format/remove_whitespace** []: Removes all whitespace from the incoming value.
81
82
  * **r/format/string_replace** [original, replacement]: Replaces all occurrences of the configured original value with the replacement value.
82
83
  * **r/format/string_template** [expression, separator, use_record]: String interpolate an expression using either the record or passed in value. Nested objects can be handled (i.e. key paths like dot-notation) by passing in a separator.
83
84
  * **r/format/substring** [start_index, end_index, exclusive]: Cut a string in a given range. All options are optional. If a start_index is not provided, the beginning of the string is used. If no end_index is specified then the end of the string is used. If exclusive is set to true then the last index position will not be included. For example: "hellofriend" with a start_index of 0, an end_index of 5, and exclusive as true would yield: "hello". If exclusive was false then it would yield "hellof"
85
+ * **r/format/uppercase** []: Calls `#to_s.upcase` on the value so the returned value is guaranteed to be an upper-cased string type.
84
86
 
85
87
  #### Logical Transformers
86
88
 
@@ -89,7 +91,7 @@ Here is a list of each built-in transformer, their options, and what their funct
89
91
  #### Type Transformers
90
92
 
91
93
  * **r/type/boolean** [nullable]: Returns `true` if the input is 'truthy', `false` if not. By default nullable is false, which means a nil input will return false. Changing this to true will return nil if nil is passed in. A 'truthy' value is defined as matching: true, t, yes, y, or 1 (case-insensitive).
92
- * **r/type/string** []: Calls `#to_s` on the value so the returned value is guaranteed to be a string type.
94
+ * **r/type/string** [nullable]: Calls `#to_s` on the value so the returned value is guaranteed to be a string type.
93
95
 
94
96
  #### Value-oriented Transformers
95
97
 
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
3
10
  module Realize
4
11
  # Mix-in that adds some nice common array helpers.
5
12
  module Arrays
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
3
10
  module Realize
4
11
  class Collection
5
12
  # Transformer to get an item of a collection
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
3
10
  module Realize
4
11
  class Collection
5
12
  # Transformer to get the first item of a collection
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
3
10
  module Realize
4
11
  class Collection
5
12
  # Transformer to get the last item of a collection
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
3
10
  require_relative 'sort/direction'
4
11
 
5
12
  module Realize
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
3
10
  module Realize
4
11
  class Collection
5
12
  class Sort
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
3
10
  module Realize
4
11
  class Filter
5
12
  # This transformer can take an array or a hash (put in array) and it understands how to
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
3
10
  module Realize
4
11
  class Filter
5
12
  # This transformer can take an array or a hash (put in array) and it understands how to
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
3
10
  module Realize
4
11
  class Filter
5
12
  # This transformer can take an object (will be converted to array) or array and
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
3
10
  module Realize
4
11
  class Filter
5
12
  # This transformer can take in an array or hash (put in an array) and filters out
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
3
10
  module Realize
4
11
  class Format
5
12
  # Formats a date/time value. If the input is nil, it will output nil. If an input_format
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
10
+ module Realize
11
+ class Format
12
+ # Call #to_s.downcase on the value and return result.
13
+ class Lowercase
14
+ acts_as_hashable
15
+
16
+ def transform(_resolver, value, _time, _record)
17
+ value.to_s.downcase
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
3
10
  module Realize
4
11
  class Format
5
12
  # This transformer takes in a value and replaces any whitespace characters (\t\r\n\f\v)
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
3
10
  module Realize
4
11
  class Format
5
12
  # This transformer takes in a value and replaces all occurrences of the given
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
3
10
  module Realize
4
11
  class Format
5
12
  # Use an expression as a template and string interpolate it using the Stringento library.
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
3
10
  module Realize
4
11
  class Format
5
12
  # Cut a string using a range (start and end index). You can also choose whether you wish the
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
10
+ module Realize
11
+ class Format
12
+ # Call #to_s.downcase on the value and return result.
13
+ class Uppercase
14
+ acts_as_hashable
15
+
16
+ def transform(_resolver, value, _time, _record)
17
+ value.to_s.upcase
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
3
10
  require_relative 'switch/case'
4
11
 
5
12
  module Realize
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
3
10
  module Realize
4
11
  class Logical
5
12
  class Switch
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
3
10
  module Realize
4
11
  # Main runner that encapsulates a collection of transformers and knows how to kick off the
5
12
  # transformation process.
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
3
10
  require_relative 'collection/at_index'
4
11
  require_relative 'collection/first'
5
12
  require_relative 'collection/last'
@@ -11,10 +18,12 @@ require_relative 'filter/by_key_value_presence'
11
18
  require_relative 'filter/inactive'
12
19
 
13
20
  require_relative 'format/date'
21
+ require_relative 'format/lowercase'
14
22
  require_relative 'format/remove_whitespace'
15
23
  require_relative 'format/string_replace'
16
24
  require_relative 'format/string_template'
17
25
  require_relative 'format/substring'
26
+ require_relative 'format/uppercase'
18
27
 
19
28
  require_relative 'logical/switch'
20
29
 
@@ -49,10 +58,12 @@ module Realize
49
58
  register 'r/filter/inactive', Filter::Inactive
50
59
 
51
60
  register 'r/format/date', Format::Date
61
+ register 'r/format/lowercase', Format::Lowercase
52
62
  register 'r/format/remove_whitespace', Format::RemoveWhitespace
53
63
  register 'r/format/string_replace', Format::StringReplace
54
64
  register 'r/format/string_template', Format::StringTemplate
55
65
  register 'r/format/substring', Format::Substring
66
+ register 'r/format/uppercase', Format::Uppercase
56
67
 
57
68
  register 'r/logical/switch', Logical::Switch
58
69
 
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
10
+ module Realize
11
+ class Type
12
+ # Common code for all Type Transformer subclasses.
13
+ class Base
14
+ acts_as_hashable
15
+
16
+ attr_reader :nullable
17
+
18
+ def initialize(nullable: false)
19
+ @nullable = nullable || false
20
+
21
+ freeze
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,5 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
10
+ require_relative 'base'
11
+
3
12
  module Realize
4
13
  class Type
5
14
  # Convert input into either true, false, or nil.
@@ -9,15 +18,7 @@ module Realize
9
18
  # All other non-truthy values will evaluate to false, such as:
10
19
  # false, 'false', 'f', 'FALSE', 'False', 0, '0', 'N', 'no', 'No', 'NO', {}, [], '',
11
20
  # 'abc', 123, :abc, etc...
12
- class Boolean
13
- acts_as_hashable
14
-
15
- attr_reader :nullable
16
-
17
- def initialize(nullable: false)
18
- @nullable = nullable || false
19
- end
20
-
21
+ class Boolean < Base
21
22
  def transform(_resolver, value, _time, _record)
22
23
  if nullable && value.nil?
23
24
  nil
@@ -1,17 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
10
+ require_relative 'base'
11
+
3
12
  module Realize
4
13
  class Type
5
14
  # Call #to_s on the value and return result.
6
- class String
7
- acts_as_hashable
8
-
9
- attr_reader :nullable
10
-
11
- def initialize(nullable: false)
12
- @nullable = nullable || false
13
- end
14
-
15
+ class String < Base
15
16
  def transform(_resolver, value, _time, _record)
16
17
  return nil if nullable && value.nil?
17
18
 
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
3
10
  module Realize
4
11
  class Value
5
12
  # Always returns blank string
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
3
10
  module Realize
4
11
  class Value
5
12
  # This transformer can take in a hash of: "value" -> "new value". It's basically a
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
3
10
  module Realize
4
11
  class Value
5
12
  # Return a current Time object.
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
3
10
  module Realize
4
11
  class Value
5
12
  # Transformer that always returns nil
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
3
10
  module Realize
4
11
  class Value
5
12
  # Basic transformer that can take an object and extract a value based off the transformer's
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
3
10
  module Realize
4
11
  class Value
5
12
  # Transformer that always returns a static value
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
3
10
  module Realize
4
11
  class Value
5
12
  # Return a current Time object.
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
3
10
  module Realize
4
11
  class Value
5
12
  # Default transformer that does nothing.
@@ -8,5 +8,5 @@
8
8
  #
9
9
 
10
10
  module Realize
11
- VERSION = '1.3.0'
11
+ VERSION = '1.4.0'
12
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: realize
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Ruggio
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2020-11-04 00:00:00.000000000 Z
12
+ date: 2020-11-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: acts_as_hashable
@@ -191,14 +191,17 @@ files:
191
191
  - lib/realize/filter/by_key_value_presence.rb
192
192
  - lib/realize/filter/inactive.rb
193
193
  - lib/realize/format/date.rb
194
+ - lib/realize/format/lowercase.rb
194
195
  - lib/realize/format/remove_whitespace.rb
195
196
  - lib/realize/format/string_replace.rb
196
197
  - lib/realize/format/string_template.rb
197
198
  - lib/realize/format/substring.rb
199
+ - lib/realize/format/uppercase.rb
198
200
  - lib/realize/logical/switch.rb
199
201
  - lib/realize/logical/switch/case.rb
200
202
  - lib/realize/pipeline.rb
201
203
  - lib/realize/transformers.rb
204
+ - lib/realize/type/base.rb
202
205
  - lib/realize/type/boolean.rb
203
206
  - lib/realize/type/string.rb
204
207
  - lib/realize/value/blank.rb