realize 1.2.0.pre.alpha → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -1
- data/.tool-versions +1 -0
- data/CHANGELOG.md +36 -5
- data/README.md +16 -3
- data/lib/realize.rb +2 -0
- data/lib/realize/arrays.rb +7 -0
- data/lib/realize/collection/at_index.rb +7 -0
- data/lib/realize/collection/first.rb +7 -0
- data/lib/realize/collection/join.rb +41 -0
- data/lib/realize/collection/last.rb +7 -0
- data/lib/realize/collection/sort.rb +7 -0
- data/lib/realize/collection/sort/direction.rb +7 -0
- data/lib/realize/file/basename.rb +32 -0
- data/lib/realize/file/extname.rb +22 -0
- data/lib/realize/filter/by_key_record_value.rb +7 -0
- data/lib/realize/filter/by_key_value.rb +7 -0
- data/lib/realize/filter/by_key_value_presence.rb +7 -0
- data/lib/realize/filter/inactive.rb +7 -0
- data/lib/realize/format/date.rb +7 -0
- data/lib/realize/format/lowercase.rb +21 -0
- data/lib/realize/format/pad.rb +61 -0
- data/lib/realize/format/remove_whitespace.rb +7 -0
- data/lib/realize/format/sha256.rb +49 -0
- data/lib/realize/format/split.rb +33 -0
- data/lib/realize/format/string_replace.rb +7 -0
- data/lib/realize/format/string_template.rb +45 -0
- data/lib/realize/format/substring.rb +51 -0
- data/lib/realize/format/uppercase.rb +21 -0
- data/lib/realize/logical/switch.rb +8 -1
- data/lib/realize/logical/switch/case.rb +7 -0
- data/lib/realize/pipeline.rb +7 -0
- data/lib/realize/transformers.rb +31 -0
- data/lib/realize/type/array.rb +36 -0
- data/lib/realize/type/base.rb +25 -0
- data/lib/realize/type/boolean.rb +14 -14
- data/lib/realize/type/string.rb +10 -9
- data/lib/realize/value/blank.rb +7 -0
- data/lib/realize/value/map.rb +7 -0
- data/lib/realize/value/now.rb +7 -0
- data/lib/realize/value/null.rb +7 -0
- data/lib/realize/value/resolve.rb +7 -0
- data/lib/realize/value/static.rb +7 -0
- data/lib/realize/value/uuid.rb +7 -0
- data/lib/realize/value/verbatim.rb +7 -0
- data/lib/realize/version.rb +1 -1
- data/realize.gemspec +4 -3
- metadata +44 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0bb0d8d3479459e62de37d0a70f348873ff1495f3053e8f2d010cfd5e8242f6
|
4
|
+
data.tar.gz: 81b79d68ea2999163daab133a6991073a75807992eff971980b166c9eddfd4cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 005c2fc49cdd4933029ba19d03ffe33308d1e41343ecc58a44ef114ea3ba7df387cb12fba74821eb1c532c75ee21a1bd8549061a454f90bf6e7bb4950135353d
|
7
|
+
data.tar.gz: 98a4548c55826a876dd27b4dce415b0666a196450691e448261d0c78d6c7310f0f7b34ea7a6fca64997fd8984003a3773331c5bcbebee9c4bb2e000b06460199
|
data/.rubocop.yml
CHANGED
@@ -4,7 +4,7 @@ Layout/LineLength:
|
|
4
4
|
- realize.gemspec
|
5
5
|
|
6
6
|
Metrics/BlockLength:
|
7
|
-
|
7
|
+
IgnoredMethods:
|
8
8
|
- let
|
9
9
|
- it
|
10
10
|
- describe
|
@@ -17,6 +17,7 @@ Metrics/MethodLength:
|
|
17
17
|
|
18
18
|
AllCops:
|
19
19
|
TargetRubyVersion: 2.5
|
20
|
+
NewCops: enable
|
20
21
|
|
21
22
|
Metrics/AbcSize:
|
22
23
|
Max: 16
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 2.6.6
|
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,42 @@
|
|
1
|
-
# 1.
|
1
|
+
# 1.6.0 (July 7th, 2021)
|
2
2
|
|
3
3
|
New Transformers:
|
4
4
|
|
5
|
-
*
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
* r/collection/join
|
6
|
+
|
7
|
+
# 1.5.0 (November 24th, 2020)
|
8
|
+
|
9
|
+
New Transformers:
|
10
|
+
|
11
|
+
* r/file/basename
|
12
|
+
* r/file/extname
|
13
|
+
* r/format/pad
|
14
|
+
* r/format/sha256
|
15
|
+
* r/format/split
|
16
|
+
* r/type/array
|
17
|
+
|
18
|
+
# 1.4.0 (November 16th, 2020)
|
19
|
+
|
20
|
+
New Transformers:
|
21
|
+
|
22
|
+
* r/format/lowercase
|
23
|
+
* r/format/uppercase
|
24
|
+
|
25
|
+
# 1.3.0 (November 4th, 2020)
|
26
|
+
|
27
|
+
New Transformers:
|
28
|
+
|
29
|
+
* r/format/string_template
|
30
|
+
* r/format/substring
|
31
|
+
|
32
|
+
# 1.2.0 (October 6th, 2020)
|
33
|
+
|
34
|
+
New Transformers:
|
35
|
+
|
36
|
+
* r/type/boolean
|
37
|
+
* r/type/string
|
38
|
+
* r/value/now
|
39
|
+
* r/value/uuid
|
9
40
|
|
10
41
|
# 1.1.1 (September 9th, 2020)
|
11
42
|
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Realize
|
2
2
|
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/realize.svg)](https://badge.fury.io/rb/realize) [![Build Status](https://travis-ci.
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/realize.svg)](https://badge.fury.io/rb/realize) [![Build Status](https://travis-ci.com/bluemarblepayroll/realize.svg?branch=master)](https://travis-ci.com/bluemarblepayroll/realize) [![Maintainability](https://api.codeclimate.com/v1/badges/115f0c5a1d0a4cce7230/maintainability)](https://codeclimate.com/github/bluemarblepayroll/realize/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/115f0c5a1d0a4cce7230/test_coverage)](https://codeclimate.com/github/bluemarblepayroll/realize/test_coverage) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
|
4
4
|
|
5
5
|
This library provides a pluggable and configurable data transformation framework. The general use-case is:
|
6
6
|
|
@@ -13,7 +13,7 @@ It is currently used in production at Blue Marble to power the transformation pi
|
|
13
13
|
To install through Rubygems:
|
14
14
|
|
15
15
|
````
|
16
|
-
gem install
|
16
|
+
gem install realize
|
17
17
|
````
|
18
18
|
|
19
19
|
You can also add this to your Gemfile:
|
@@ -64,9 +64,14 @@ Here is a list of each built-in transformer, their options, and what their funct
|
|
64
64
|
|
65
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
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/join** [separator, start_index, end_index]: Takes an array (or coerces value to an array) and returns a new string by concatenating all the elements of the array by a separator character. Can also specifiy which elements to start from and end to that will make up the returned string.
|
67
68
|
* **r/collection/last** []: Takes an array (or coerces value to an array) and returns the value at the last index position.
|
68
69
|
* **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.
|
69
70
|
|
71
|
+
#### File-based Transformers
|
72
|
+
|
73
|
+
* **r/file/basename** [suffix]: Return the filename and extension. If suffix is provided then it will be stripped from the end. If '.*' is passed as the suffix then any extension will be ignored.
|
74
|
+
* **r/file/extname** [suffix]: Return the extension for value.
|
70
75
|
#### Filtering Transformers
|
71
76
|
|
72
77
|
* **r/filter/by_key_record_value** [key, value]: Takes an array (or coerces value to an array) and selects only the records that match the key's value. In this case the value is derived off of the main record.
|
@@ -77,8 +82,15 @@ Here is a list of each built-in transformer, their options, and what their funct
|
|
77
82
|
#### Format-oriented Transformers
|
78
83
|
|
79
84
|
* **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.
|
85
|
+
* **r/format/lowercase** []: Calls `#to_s.downcase` on the value so the returned value is guaranteed to be a lower-cased string.
|
86
|
+
* **r/format/pad** [length, side, with]: Pad a string value with a specified 'with' value (defaults to blank space) up until the passed in length is reached. The 'side' option can be used to specify whether the padding should occur to the left or right side of the value.
|
80
87
|
* **r/format/remove_whitespace** []: Removes all whitespace from the incoming value.
|
88
|
+
* **r/format/sha256** [encoding_format]: Convert the value into a SHA256 encoded string. The encoding_format will be hex by default but can also be configured to use base64.
|
89
|
+
* **r/format/split** [by]: Take a string value and split it on the specified 'by' value. By default, it will be split on a blank space.
|
81
90
|
* **r/format/string_replace** [original, replacement]: Replaces all occurrences of the configured original value with the replacement value.
|
91
|
+
* **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.
|
92
|
+
* **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"
|
93
|
+
* **r/format/uppercase** []: Calls `#to_s.upcase` on the value so the returned value is guaranteed to be an upper-cased string type.
|
82
94
|
|
83
95
|
#### Logical Transformers
|
84
96
|
|
@@ -86,8 +98,9 @@ Here is a list of each built-in transformer, their options, and what their funct
|
|
86
98
|
|
87
99
|
#### Type Transformers
|
88
100
|
|
101
|
+
* **r/type/array** [nullable]: Ensure the value is an array by calling Kernel#Array on the value.
|
89
102
|
* **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).
|
90
|
-
* **r/type/string** []: Calls `#to_s` on the value so the returned value is guaranteed to be a string type.
|
103
|
+
* **r/type/string** [nullable]: Calls `#to_s` on the value so the returned value is guaranteed to be a string type.
|
91
104
|
|
92
105
|
#### Value-oriented Transformers
|
93
106
|
|
data/lib/realize.rb
CHANGED
data/lib/realize/arrays.rb
CHANGED
@@ -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
|
@@ -0,0 +1,41 @@
|
|
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 Collection
|
12
|
+
# Transformer to return a new string by concatenating all the elements of an array
|
13
|
+
# specified by a separator character. The transformer also can be configured to specifiy
|
14
|
+
# which elements to start from and end to that will make up the returned string.
|
15
|
+
class Join
|
16
|
+
include Arrays
|
17
|
+
acts_as_hashable
|
18
|
+
|
19
|
+
DEFAULT_END_INDEX = -1
|
20
|
+
DEFAULT_SEPARATOR = ''
|
21
|
+
DEFAULT_START_INDEX = 0
|
22
|
+
|
23
|
+
attr_reader :separator, :end_index, :start_index
|
24
|
+
|
25
|
+
def initialize(separator: DEFAULT_SEPARATOR, start_index: DEFAULT_START_INDEX,
|
26
|
+
end_index: DEFAULT_END_INDEX)
|
27
|
+
@separator = separator || DEFAULT_SEPARATOR
|
28
|
+
@start_index = start_index || DEFAULT_START_INDEX
|
29
|
+
@end_index = end_index || DEFAULT_END_INDEX
|
30
|
+
|
31
|
+
freeze
|
32
|
+
end
|
33
|
+
|
34
|
+
def transform(_resolver, value, _time, _record)
|
35
|
+
items = array(value)
|
36
|
+
|
37
|
+
(items[start_index..end_index] || []).join(separator)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
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 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
|
@@ -0,0 +1,32 @@
|
|
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 File
|
12
|
+
# Takes the value and strips out the directory. Suffix is provided as an option which strips
|
13
|
+
# out the extension (last period and beyond). If '.*' is passed in as the suffix then any
|
14
|
+
# extension will be stripped. Note that files with multiple extensions will only have their
|
15
|
+
# last extesion removed.
|
16
|
+
class Basename
|
17
|
+
acts_as_hashable
|
18
|
+
|
19
|
+
attr_reader :suffix
|
20
|
+
|
21
|
+
def initialize(suffix: '')
|
22
|
+
@suffix = suffix.to_s
|
23
|
+
|
24
|
+
freeze
|
25
|
+
end
|
26
|
+
|
27
|
+
def transform(_resolver, value, _time, _record)
|
28
|
+
::File.basename(value.to_s, suffix)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,22 @@
|
|
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 File
|
12
|
+
# Extract the file extension from the value. If the value has multiple extensions then
|
13
|
+
# only the last one will be returned.
|
14
|
+
class Extname
|
15
|
+
acts_as_hashable
|
16
|
+
|
17
|
+
def transform(_resolver, value, _time, _record)
|
18
|
+
::File.extname(value.to_s)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
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 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
|
data/lib/realize/format/date.rb
CHANGED
@@ -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
|
@@ -0,0 +1,61 @@
|
|
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
|
+
# Pad a string value with a specified 'with' value (defaults to blank space) up until the
|
13
|
+
# passed in length is reached. The 'side' option can be used to specify whether the
|
14
|
+
# padding should occur to the left or right side of the value.
|
15
|
+
# Examples:
|
16
|
+
# 'ABC' + [length: 10, side: 'left', with: '123'] => '1231231ABC'
|
17
|
+
# 'ABC' + [length: 10, side: 'right, with: '123'] => 'ABC1231231'
|
18
|
+
#
|
19
|
+
# If length is not specified or is less than the actual value's length then no padding
|
20
|
+
# will occur.
|
21
|
+
class Pad
|
22
|
+
acts_as_hashable
|
23
|
+
|
24
|
+
module Side
|
25
|
+
LEFT = :left
|
26
|
+
RIGHT = :right
|
27
|
+
end
|
28
|
+
include Side
|
29
|
+
|
30
|
+
DEFAULT_SIDE = LEFT
|
31
|
+
DEFAULT_WITH = ' '
|
32
|
+
|
33
|
+
attr_reader :length, :side, :with
|
34
|
+
|
35
|
+
def initialize(length: nil, side: LEFT, with: DEFAULT_WITH)
|
36
|
+
@length = length ? length.to_i : nil
|
37
|
+
@side = Side.const_get(side.to_s.upcase.to_sym)
|
38
|
+
@with = with.to_s
|
39
|
+
|
40
|
+
freeze
|
41
|
+
end
|
42
|
+
|
43
|
+
def transform(_resolver, value, _time, _record)
|
44
|
+
return value unless length
|
45
|
+
|
46
|
+
value.to_s.send(just_method, length, with)
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def just_method
|
52
|
+
case side
|
53
|
+
when LEFT
|
54
|
+
:rjust
|
55
|
+
when RIGHT
|
56
|
+
:ljust
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
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)
|
@@ -0,0 +1,49 @@
|
|
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
|
+
# Convert the value into a SHA256 encoded string. There are two main encoding formats:
|
13
|
+
# hex or base64. By default, the value will be hexidecimal encoded.
|
14
|
+
class Sha256
|
15
|
+
acts_as_hashable
|
16
|
+
|
17
|
+
module EncodingFormat
|
18
|
+
HEX = :hex
|
19
|
+
BASE64 = :base64
|
20
|
+
end
|
21
|
+
include EncodingFormat
|
22
|
+
|
23
|
+
DEFAULT_ENCODING_FORMAT = HEX
|
24
|
+
|
25
|
+
attr_reader :encoding_format
|
26
|
+
|
27
|
+
def initialize(encoding_format: DEFAULT_ENCODING_FORMAT)
|
28
|
+
@encoding_format = EncodingFormat.const_get(encoding_format.to_s.upcase.to_sym)
|
29
|
+
|
30
|
+
freeze
|
31
|
+
end
|
32
|
+
|
33
|
+
def transform(_resolver, value, _time, _record)
|
34
|
+
Digest::SHA256.send(sha_method, value.to_s)
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def sha_method
|
40
|
+
case encoding_format
|
41
|
+
when HEX
|
42
|
+
:hexdigest
|
43
|
+
when BASE64
|
44
|
+
:base64digest
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,33 @@
|
|
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
|
+
# Take a string value and split it on the specified 'by' value. By default, it will be
|
13
|
+
# split on a blank space. For example: '123 456 789' would yield ['123', '456', '789'].
|
14
|
+
# If the value is not a string then it will be converted to a string by calling #to_s on it.
|
15
|
+
class Split
|
16
|
+
acts_as_hashable
|
17
|
+
|
18
|
+
DEFAULT_BY = ' '
|
19
|
+
|
20
|
+
attr_reader :by
|
21
|
+
|
22
|
+
def initialize(by: DEFAULT_BY)
|
23
|
+
@by = by.to_s
|
24
|
+
|
25
|
+
freeze
|
26
|
+
end
|
27
|
+
|
28
|
+
def transform(_resolver, value, _time, _record)
|
29
|
+
value.to_s.split(by)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
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 all occurrences of the given
|
@@ -0,0 +1,45 @@
|
|
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
|
+
# Use an expression as a template and string interpolate it using the Stringento library.
|
13
|
+
# Stringento also uses Objectable to provide (optional) key-path notation for handling
|
14
|
+
# nested objects.
|
15
|
+
# For more information see underlying libraries:
|
16
|
+
# * Stringento: https://github.com/bluemarblepayroll/stringento
|
17
|
+
# * Objectable: https://github.com/bluemarblepayroll/objectable
|
18
|
+
class StringTemplate
|
19
|
+
acts_as_hashable
|
20
|
+
|
21
|
+
DEFAULT_SEPARATOR = '.'
|
22
|
+
|
23
|
+
attr_reader :expression, :resolver, :use_record
|
24
|
+
|
25
|
+
def initialize(expression: '', separator: DEFAULT_SEPARATOR, use_record: false)
|
26
|
+
@expression = expression.to_s
|
27
|
+
@resolver = Objectable.resolver(separator: separator)
|
28
|
+
@use_record = use_record || false
|
29
|
+
|
30
|
+
freeze
|
31
|
+
end
|
32
|
+
|
33
|
+
def transform(_resolver, value, _time, record)
|
34
|
+
input = use_record ? record : value
|
35
|
+
|
36
|
+
Stringento.evaluate(expression, input, resolver: self)
|
37
|
+
end
|
38
|
+
|
39
|
+
# For Stringento consumption
|
40
|
+
def resolve(value, input)
|
41
|
+
resolver.get(input, value)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,51 @@
|
|
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
|
+
# Cut a string using a range (start and end index). You can also choose whether you wish the
|
13
|
+
# range selection to be inclusive (default) or exclusive.
|
14
|
+
#
|
15
|
+
# Examples using the string: '012-345-6789'
|
16
|
+
#
|
17
|
+
# Exclusive vs. Inclusive
|
18
|
+
#
|
19
|
+
# [start_index: 4, end_index: 6, exclusive: false] => '345'
|
20
|
+
# [start_index: 4, end_index: 6, exclusive: true] => '34'
|
21
|
+
#
|
22
|
+
# Default Values / Omitted Options
|
23
|
+
#
|
24
|
+
# [end_index: 6] => '012-345'
|
25
|
+
# [start_index: 4] => '345-6789'
|
26
|
+
class Substring
|
27
|
+
acts_as_hashable
|
28
|
+
|
29
|
+
DEFAULT_END_INDEX = -1
|
30
|
+
DEFAULT_START_INDEX = 0
|
31
|
+
|
32
|
+
attr_reader :end_index, :exclusive, :start_index
|
33
|
+
|
34
|
+
def initialize(
|
35
|
+
end_index: DEFAULT_END_INDEX,
|
36
|
+
exclusive: false,
|
37
|
+
start_index: DEFAULT_START_INDEX
|
38
|
+
)
|
39
|
+
@end_index = end_index.to_i
|
40
|
+
@exclusive = exclusive || false
|
41
|
+
@start_index = start_index.to_i
|
42
|
+
|
43
|
+
freeze
|
44
|
+
end
|
45
|
+
|
46
|
+
def transform(_resolver, value, _time, _record)
|
47
|
+
exclusive ? value.to_s[start_index...end_index] : value.to_s[start_index..end_index]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -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
|
@@ -14,7 +21,7 @@ module Realize
|
|
14
21
|
|
15
22
|
attr_reader :cases, :default_transformers, :key
|
16
23
|
|
17
|
-
def initialize(cases: [], default_transformers: []
|
24
|
+
def initialize(key:, cases: [], default_transformers: [])
|
18
25
|
raise ArgumentError, 'key is required' if key.to_s.empty?
|
19
26
|
|
20
27
|
@cases = Case.array(cases)
|
@@ -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
|
data/lib/realize/pipeline.rb
CHANGED
@@ -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.
|
data/lib/realize/transformers.rb
CHANGED
@@ -1,9 +1,20 @@
|
|
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'
|
6
13
|
require_relative 'collection/sort'
|
14
|
+
require_relative 'collection/join'
|
15
|
+
|
16
|
+
require_relative 'file/basename'
|
17
|
+
require_relative 'file/extname'
|
7
18
|
|
8
19
|
require_relative 'filter/by_key_record_value'
|
9
20
|
require_relative 'filter/by_key_value'
|
@@ -11,11 +22,19 @@ require_relative 'filter/by_key_value_presence'
|
|
11
22
|
require_relative 'filter/inactive'
|
12
23
|
|
13
24
|
require_relative 'format/date'
|
25
|
+
require_relative 'format/lowercase'
|
26
|
+
require_relative 'format/pad'
|
14
27
|
require_relative 'format/remove_whitespace'
|
28
|
+
require_relative 'format/sha256'
|
29
|
+
require_relative 'format/split'
|
15
30
|
require_relative 'format/string_replace'
|
31
|
+
require_relative 'format/string_template'
|
32
|
+
require_relative 'format/substring'
|
33
|
+
require_relative 'format/uppercase'
|
16
34
|
|
17
35
|
require_relative 'logical/switch'
|
18
36
|
|
37
|
+
require_relative 'type/array'
|
19
38
|
require_relative 'type/boolean'
|
20
39
|
require_relative 'type/string'
|
21
40
|
|
@@ -40,6 +59,10 @@ module Realize
|
|
40
59
|
register 'r/collection/first', Collection::First
|
41
60
|
register 'r/collection/last', Collection::Last
|
42
61
|
register 'r/collection/sort', Collection::Sort
|
62
|
+
register 'r/collection/join', Collection::Join
|
63
|
+
|
64
|
+
register 'r/file/basename', File::Basename
|
65
|
+
register 'r/file/extname', File::Extname
|
43
66
|
|
44
67
|
register 'r/filter/by_key_record_value', Filter::ByKeyRecordValue
|
45
68
|
register 'r/filter/by_key_value', Filter::ByKeyValue
|
@@ -47,11 +70,19 @@ module Realize
|
|
47
70
|
register 'r/filter/inactive', Filter::Inactive
|
48
71
|
|
49
72
|
register 'r/format/date', Format::Date
|
73
|
+
register 'r/format/lowercase', Format::Lowercase
|
74
|
+
register 'r/format/pad', Format::Pad
|
50
75
|
register 'r/format/remove_whitespace', Format::RemoveWhitespace
|
76
|
+
register 'r/format/sha256', Format::Sha256
|
77
|
+
register 'r/format/split', Format::Split
|
51
78
|
register 'r/format/string_replace', Format::StringReplace
|
79
|
+
register 'r/format/string_template', Format::StringTemplate
|
80
|
+
register 'r/format/substring', Format::Substring
|
81
|
+
register 'r/format/uppercase', Format::Uppercase
|
52
82
|
|
53
83
|
register 'r/logical/switch', Logical::Switch
|
54
84
|
|
85
|
+
register 'r/type/array', Type::Array
|
55
86
|
register 'r/type/boolean', Type::Boolean
|
56
87
|
register 'r/type/string', Type::String
|
57
88
|
|
@@ -0,0 +1,36 @@
|
|
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
|
+
require_relative 'base'
|
11
|
+
|
12
|
+
module Realize
|
13
|
+
class Type
|
14
|
+
# Ensure the value is an array by calling Kernel#Array on the value. If the value is a hash
|
15
|
+
# then it will ensure the hash data structure is preserved and placed within the array.
|
16
|
+
# Normally calling Array(hash) would yield an array of key-value pair arrays. For our
|
17
|
+
# pipeline we generally treat hashes as "record-like" objects, so we need to ensure
|
18
|
+
# we keep it in tact.
|
19
|
+
#
|
20
|
+
# This does not mean other data types do not suffer from Kernel#Array
|
21
|
+
# converting it to something unexpected. For example, passing in a Time object would yield
|
22
|
+
# an array of parts:
|
23
|
+
# Array(Time.now) => [2, 59, 10, 21, 11, 2020, 6, 326, false, "CST"]
|
24
|
+
#
|
25
|
+
# See: https://ruby-doc.org/core-2.7.2/Kernel.html#method-i-Array for more information.
|
26
|
+
class Array < Base
|
27
|
+
include Arrays
|
28
|
+
|
29
|
+
def transform(_resolver, value, _time, _record)
|
30
|
+
return nil if nullable && value.nil?
|
31
|
+
|
32
|
+
array(value)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -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
|
data/lib/realize/type/boolean.rb
CHANGED
@@ -1,29 +1,29 @@
|
|
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.
|
6
15
|
# By default nils will return false unless nullable: true is passed in.
|
7
16
|
# This transformer is very liberal in its parsing and will return true for:
|
8
17
|
# true, 'true', 't', 'TRUE', 'True', 1, '1', 'Y', 'yes', 'Yes', 'YES'
|
9
|
-
# All
|
10
|
-
# false
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
attr_reader :nullable
|
15
|
-
|
16
|
-
def initialize(nullable: false)
|
17
|
-
@nullable = nullable || false
|
18
|
-
end
|
19
|
-
|
18
|
+
# All other non-truthy values will evaluate to false, such as:
|
19
|
+
# false, 'false', 'f', 'FALSE', 'False', 0, '0', 'N', 'no', 'No', 'NO', {}, [], '',
|
20
|
+
# 'abc', 123, :abc, etc...
|
21
|
+
class Boolean < Base
|
20
22
|
def transform(_resolver, value, _time, _record)
|
21
23
|
if nullable && value.nil?
|
22
24
|
nil
|
23
|
-
elsif truthy?(value)
|
24
|
-
true
|
25
25
|
else
|
26
|
-
|
26
|
+
truthy?(value)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
data/lib/realize/type/string.rb
CHANGED
@@ -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
|
|
data/lib/realize/value/blank.rb
CHANGED
@@ -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
|
data/lib/realize/value/map.rb
CHANGED
@@ -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
|
data/lib/realize/value/now.rb
CHANGED
@@ -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.
|
data/lib/realize/value/null.rb
CHANGED
@@ -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
|
data/lib/realize/value/static.rb
CHANGED
@@ -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
|
data/lib/realize/value/uuid.rb
CHANGED
@@ -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.
|
data/lib/realize/version.rb
CHANGED
data/realize.gemspec
CHANGED
@@ -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', 'Dan Dewar']
|
15
|
-
s.email = ['mruggio@bluemarblepayroll.com', 'ddewar@bluemarblepayroll.com']
|
14
|
+
s.authors = ['Matthew Ruggio', 'Dan Dewar', 'John Bosko']
|
15
|
+
s.email = ['mruggio@bluemarblepayroll.com', 'ddewar@bluemarblepayroll.com', 'jbosko@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 = []
|
@@ -30,12 +30,13 @@ Gem::Specification.new do |s|
|
|
30
30
|
|
31
31
|
s.add_dependency('acts_as_hashable', '~>1', '>=1.2.0')
|
32
32
|
s.add_dependency('objectable', '~>1')
|
33
|
+
s.add_dependency('stringento', '~>2.1')
|
33
34
|
|
34
35
|
s.add_development_dependency('guard-rspec', '~>4.7')
|
35
36
|
s.add_development_dependency('pry', '~>0')
|
36
37
|
s.add_development_dependency('rake', '~> 13')
|
37
38
|
s.add_development_dependency('rspec')
|
38
|
-
s.add_development_dependency('rubocop', '~>
|
39
|
+
s.add_development_dependency('rubocop', '~>1.1', '>=1.18.1')
|
39
40
|
s.add_development_dependency('simplecov', '~>0.17.0')
|
40
41
|
s.add_development_dependency('simplecov-console', '~>0.6.0')
|
41
42
|
end
|
metadata
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: realize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Ruggio
|
8
8
|
- Dan Dewar
|
9
|
-
|
9
|
+
- John Bosko
|
10
|
+
autorequire:
|
10
11
|
bindir: exe
|
11
12
|
cert_chain: []
|
12
|
-
date:
|
13
|
+
date: 2021-07-07 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: acts_as_hashable
|
@@ -45,6 +46,20 @@ dependencies:
|
|
45
46
|
- - "~>"
|
46
47
|
- !ruby/object:Gem::Version
|
47
48
|
version: '1'
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: stringento
|
51
|
+
requirement: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '2.1'
|
56
|
+
type: :runtime
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '2.1'
|
48
63
|
- !ruby/object:Gem::Dependency
|
49
64
|
name: guard-rspec
|
50
65
|
requirement: !ruby/object:Gem::Requirement
|
@@ -107,14 +122,20 @@ dependencies:
|
|
107
122
|
requirements:
|
108
123
|
- - "~>"
|
109
124
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
125
|
+
version: '1.1'
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: 1.18.1
|
111
129
|
type: :development
|
112
130
|
prerelease: false
|
113
131
|
version_requirements: !ruby/object:Gem::Requirement
|
114
132
|
requirements:
|
115
133
|
- - "~>"
|
116
134
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
135
|
+
version: '1.1'
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 1.18.1
|
118
139
|
- !ruby/object:Gem::Dependency
|
119
140
|
name: simplecov
|
120
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -147,6 +168,7 @@ description: " Derive and transform a value using a configuration-first pipel
|
|
147
168
|
email:
|
148
169
|
- mruggio@bluemarblepayroll.com
|
149
170
|
- ddewar@bluemarblepayroll.com
|
171
|
+
- jbosko@bluemarblepayroll.com
|
150
172
|
executables: []
|
151
173
|
extensions: []
|
152
174
|
extra_rdoc_files: []
|
@@ -155,6 +177,7 @@ files:
|
|
155
177
|
- ".gitignore"
|
156
178
|
- ".rubocop.yml"
|
157
179
|
- ".ruby-version"
|
180
|
+
- ".tool-versions"
|
158
181
|
- ".travis.yml"
|
159
182
|
- CHANGELOG.md
|
160
183
|
- CODE_OF_CONDUCT.md
|
@@ -169,20 +192,32 @@ files:
|
|
169
192
|
- lib/realize/arrays.rb
|
170
193
|
- lib/realize/collection/at_index.rb
|
171
194
|
- lib/realize/collection/first.rb
|
195
|
+
- lib/realize/collection/join.rb
|
172
196
|
- lib/realize/collection/last.rb
|
173
197
|
- lib/realize/collection/sort.rb
|
174
198
|
- lib/realize/collection/sort/direction.rb
|
199
|
+
- lib/realize/file/basename.rb
|
200
|
+
- lib/realize/file/extname.rb
|
175
201
|
- lib/realize/filter/by_key_record_value.rb
|
176
202
|
- lib/realize/filter/by_key_value.rb
|
177
203
|
- lib/realize/filter/by_key_value_presence.rb
|
178
204
|
- lib/realize/filter/inactive.rb
|
179
205
|
- lib/realize/format/date.rb
|
206
|
+
- lib/realize/format/lowercase.rb
|
207
|
+
- lib/realize/format/pad.rb
|
180
208
|
- lib/realize/format/remove_whitespace.rb
|
209
|
+
- lib/realize/format/sha256.rb
|
210
|
+
- lib/realize/format/split.rb
|
181
211
|
- lib/realize/format/string_replace.rb
|
212
|
+
- lib/realize/format/string_template.rb
|
213
|
+
- lib/realize/format/substring.rb
|
214
|
+
- lib/realize/format/uppercase.rb
|
182
215
|
- lib/realize/logical/switch.rb
|
183
216
|
- lib/realize/logical/switch/case.rb
|
184
217
|
- lib/realize/pipeline.rb
|
185
218
|
- lib/realize/transformers.rb
|
219
|
+
- lib/realize/type/array.rb
|
220
|
+
- lib/realize/type/base.rb
|
186
221
|
- lib/realize/type/boolean.rb
|
187
222
|
- lib/realize/type/string.rb
|
188
223
|
- lib/realize/value/blank.rb
|
@@ -204,7 +239,7 @@ metadata:
|
|
204
239
|
documentation_uri: https://www.rubydoc.info/gems/realize
|
205
240
|
homepage_uri: https://github.com/bluemarblepayroll/realize
|
206
241
|
source_code_uri: https://github.com/bluemarblepayroll/realize
|
207
|
-
post_install_message:
|
242
|
+
post_install_message:
|
208
243
|
rdoc_options: []
|
209
244
|
require_paths:
|
210
245
|
- lib
|
@@ -215,12 +250,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
215
250
|
version: '2.5'
|
216
251
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
217
252
|
requirements:
|
218
|
-
- - "
|
253
|
+
- - ">="
|
219
254
|
- !ruby/object:Gem::Version
|
220
|
-
version:
|
255
|
+
version: '0'
|
221
256
|
requirements: []
|
222
257
|
rubygems_version: 3.0.3
|
223
|
-
signing_key:
|
258
|
+
signing_key:
|
224
259
|
specification_version: 4
|
225
260
|
summary: Configurable Data Transformation Pipeline
|
226
261
|
test_files: []
|