burner 1.10.0 → 1.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +2 -1
- data/lib/burner/job_with_dynamic_keys.rb +33 -0
- data/lib/burner/job_with_register.rb +2 -0
- data/lib/burner/jobs.rb +2 -1
- data/lib/burner/library.rb +2 -1
- data/lib/burner/library/collection/flat_file_parse.rb +57 -0
- data/lib/burner/library/collection/only_keys.rb +1 -20
- data/lib/burner/library/collection/transform.rb +0 -2
- data/lib/burner/library/param/base.rb +0 -2
- data/lib/burner/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f687d9818e7a090c0999f144096eef52c5ba7093a069a8d2ef784f5abdb859d7
|
4
|
+
data.tar.gz: cae3bb23c2671ab69263fe7359c93a47777c72fc387ab93a03006c38a2bc83cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d1740b55ec51e3459092d99165f75197dcad75d2dcce28ae285ed9dc1e1fcbb2a85002f8abeb868e0bc388424e8e85056bab1b41a54046023d06fbd836f0598
|
7
|
+
data.tar.gz: bffbcf8567d03252bc04fb8e207674595b271635da2ef4cec963cd6ac329e4e58194167f0b474dc522785cbaef10a239b504e12825c56fb9d55042f4733b1840
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -266,12 +266,13 @@ This library only ships with very basic, rudimentary jobs that are meant to just
|
|
266
266
|
* **b/collection/arrays_to_objects** [mappings, register]: Convert an array of arrays to an array of objects.
|
267
267
|
* **b/collection/coalesce** [grouped_register, insensitive, key_mappings, keys, register, separator]: Merge two datasets together based on the key values of one dataset (array) with a grouped dataset (hash). If insensitive (false by default) is true then each key's value will be converted/coerced to a lowercase string.
|
268
268
|
* **b/collection/concatenate** [from_registers, to_register]: Concatenate each from_register's value and place the newly concatenated array into the to_register. Note: this does not do any deep copying and should be assumed it is shallow copying all objects.
|
269
|
+
* **b/collection/flat_file_parse** [keys_register, register, separator]: Map an array of arrays to an array of hashes. These keys can be realized at run-time as they are pulled from the first entry in the array. The `keys_register` will also be set to the keys used for mapping.
|
269
270
|
* **b/collection/graph** [config, key, register]: Use [Hashematics](https://github.com/bluemarblepayroll/hashematics) to turn a flat array of objects into a deeply nested object tree.
|
270
271
|
* **b/collection/group** [insensitive, keys, register, separator]: Take a register's value (an array of objects) and group the objects by the specified keys. If insensitive (false by default) is true then each key's value will be converted/coerced to a lowercase string.
|
271
272
|
* **b/collection/nested_aggregate** [register, key_mappings, key, separator]: Traverse a set of objects, resolving key's value for each object, optionally copying down key_mappings to the child records, then merging all the inner records together.
|
272
273
|
* **b/collection/number** [key, register, separator, start_at]: This job can iterate over a set of records and sequence them (set the specified key to a sequential index value.)
|
273
274
|
* **b/collection/objects_to_arrays** [mappings, register]: Convert an array of objects to an array of arrays.
|
274
|
-
* **b/collection/only_keys** [keys_register, register, separator]: Limit an array of objects' keys to a specified set of keys. These keys can be realized at run-time as they are pulled from another register (keys_register) thus making it dynamic.
|
275
|
+
* **b/collection/only_keys** [keys_register, register, separator]: Limit an array of objects' keys to a specified set of keys. These keys can be realized at run-time as they are pulled from another register (`keys_register`) thus making it dynamic.
|
275
276
|
* **b/collection/pivot** [unique_keys, insensitive, other_keys, pivot_key, pivot_value_key, register, separator]:
|
276
277
|
Take an array of objects and pivot a key into multiple keys. It essentially takes all the values for a key and creates N number of keys (one per value.) Under the hood it uses HashMath's [Record](https://github.com/bluemarblepayroll/hash_math#record-the-hash-prototype) and [Table](https://github.com/bluemarblepayroll/hash_math#table-the-double-hash-hash-of-hashes) classes.
|
277
278
|
* **b/collection/shift** [amount, register]: Remove the first N number of elements from an array.
|
@@ -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
|
+
require_relative 'job_with_register'
|
11
|
+
|
12
|
+
module Burner
|
13
|
+
# Add on a register attribute to the configuration for a job. This indicates that a job
|
14
|
+
# either accesses and/or mutates the payload's registers.
|
15
|
+
class JobWithDynamicKeys < JobWithRegister
|
16
|
+
attr_reader :keys_register,
|
17
|
+
:resolver
|
18
|
+
|
19
|
+
def initialize(
|
20
|
+
keys_register:,
|
21
|
+
name: '',
|
22
|
+
register: DEFAULT_REGISTER,
|
23
|
+
separator: BLANK
|
24
|
+
)
|
25
|
+
super(name: name, register: register)
|
26
|
+
|
27
|
+
@keys_register = keys_register.to_s
|
28
|
+
@resolver = Objectable.resolver(separator: separator)
|
29
|
+
|
30
|
+
freeze
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -13,6 +13,8 @@ module Burner
|
|
13
13
|
# Add on a register attribute to the configuration for a job. This indicates that a job
|
14
14
|
# either accesses and/or mutates the payload's registers.
|
15
15
|
class JobWithRegister < Job
|
16
|
+
BLANK = ''
|
17
|
+
|
16
18
|
attr_reader :register
|
17
19
|
|
18
20
|
def initialize(name: '', register: DEFAULT_REGISTER)
|
data/lib/burner/jobs.rb
CHANGED
@@ -25,8 +25,9 @@ module Burner
|
|
25
25
|
register 'b/collection/arrays_to_objects', Library::Collection::ArraysToObjects
|
26
26
|
register 'b/collection/coalesce', Library::Collection::Coalesce
|
27
27
|
register 'b/collection/concatenate', Library::Collection::Concatenate
|
28
|
-
register 'b/collection/graph', Library::Collection::Graph
|
29
28
|
register 'b/collection/group', Library::Collection::Group
|
29
|
+
register 'b/collection/flat_file_parse', Library::Collection::FlatFileParse
|
30
|
+
register 'b/collection/graph', Library::Collection::Graph
|
30
31
|
register 'b/collection/nested_aggregate', Library::Collection::NestedAggregate
|
31
32
|
register 'b/collection/number', Library::Collection::Number
|
32
33
|
register 'b/collection/objects_to_arrays', Library::Collection::ObjectsToArrays
|
data/lib/burner/library.rb
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
# LICENSE file in the root directory of this source tree.
|
8
8
|
#
|
9
9
|
|
10
|
-
require_relative '
|
10
|
+
require_relative 'job_with_dynamic_keys'
|
11
11
|
|
12
12
|
require_relative 'library/echo'
|
13
13
|
require_relative 'library/nothing'
|
@@ -16,6 +16,7 @@ require_relative 'library/sleep'
|
|
16
16
|
require_relative 'library/collection/arrays_to_objects'
|
17
17
|
require_relative 'library/collection/coalesce'
|
18
18
|
require_relative 'library/collection/concatenate'
|
19
|
+
require_relative 'library/collection/flat_file_parse'
|
19
20
|
require_relative 'library/collection/graph'
|
20
21
|
require_relative 'library/collection/group'
|
21
22
|
require_relative 'library/collection/nested_aggregate'
|
@@ -0,0 +1,57 @@
|
|
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 Burner
|
11
|
+
module Library
|
12
|
+
module Collection
|
13
|
+
# Convert an array of arrays to an array of objects. The difference between this
|
14
|
+
# job and ArraysToObjects is that this one does not take in mappings and instead
|
15
|
+
# will use the first entry as the array of keys to positionally map to.
|
16
|
+
#
|
17
|
+
# For example, if a register had this:
|
18
|
+
#
|
19
|
+
# [['id', 'first', 'last'], [1, 'frank', 'rizzo']]
|
20
|
+
#
|
21
|
+
# Then executing this job would result in this:
|
22
|
+
#
|
23
|
+
# [{ 'id' => 1, 'first' => frank, 'last' => rizzo }]
|
24
|
+
#
|
25
|
+
# As a side-effect, the keys_register would result in this:
|
26
|
+
#
|
27
|
+
# ['id', 'first', 'last']
|
28
|
+
#
|
29
|
+
# Expected Payload[register] input: array of arrays.
|
30
|
+
# Payload[register] output: An array of hashes.
|
31
|
+
class FlatFileParse < JobWithDynamicKeys
|
32
|
+
def perform(output, payload)
|
33
|
+
objects = array(payload[register])
|
34
|
+
keys = array(objects.shift)
|
35
|
+
count = objects.length
|
36
|
+
|
37
|
+
output.detail("Mapping #{count} array(s) to key(s): #{keys.join(', ')}")
|
38
|
+
|
39
|
+
payload[register] = objects.map { |object| transform(object, keys) }
|
40
|
+
payload[keys_register] = keys
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def transform(object, keys)
|
46
|
+
object.each_with_object({}).with_index do |(value, memo), index|
|
47
|
+
next if index >= keys.length
|
48
|
+
|
49
|
+
key = keys[index]
|
50
|
+
|
51
|
+
resolver.set(memo, key, value)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -16,26 +16,7 @@ module Burner
|
|
16
16
|
#
|
17
17
|
# Expected Payload[register] input: array of objects.
|
18
18
|
# Payload[register] output: An array of objects.
|
19
|
-
class OnlyKeys <
|
20
|
-
BLANK = ''
|
21
|
-
|
22
|
-
attr_reader :keys_register,
|
23
|
-
:resolver
|
24
|
-
|
25
|
-
def initialize(
|
26
|
-
keys_register:,
|
27
|
-
name: '',
|
28
|
-
register: DEFAULT_REGISTER,
|
29
|
-
separator: BLANK
|
30
|
-
)
|
31
|
-
super(name: name, register: register)
|
32
|
-
|
33
|
-
@keys_register = keys_register.to_s
|
34
|
-
@resolver = Objectable.resolver(separator: separator)
|
35
|
-
|
36
|
-
freeze
|
37
|
-
end
|
38
|
-
|
19
|
+
class OnlyKeys < JobWithDynamicKeys
|
39
20
|
def perform(output, payload)
|
40
21
|
objects = array(payload[register])
|
41
22
|
count = objects.length
|
data/lib/burner/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: burner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Ruggio
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-05-
|
11
|
+
date: 2021-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: acts_as_hashable
|
@@ -240,12 +240,14 @@ files:
|
|
240
240
|
- lib/burner/disks/local.rb
|
241
241
|
- lib/burner/job.rb
|
242
242
|
- lib/burner/job_set.rb
|
243
|
+
- lib/burner/job_with_dynamic_keys.rb
|
243
244
|
- lib/burner/job_with_register.rb
|
244
245
|
- lib/burner/jobs.rb
|
245
246
|
- lib/burner/library.rb
|
246
247
|
- lib/burner/library/collection/arrays_to_objects.rb
|
247
248
|
- lib/burner/library/collection/coalesce.rb
|
248
249
|
- lib/burner/library/collection/concatenate.rb
|
250
|
+
- lib/burner/library/collection/flat_file_parse.rb
|
249
251
|
- lib/burner/library/collection/graph.rb
|
250
252
|
- lib/burner/library/collection/group.rb
|
251
253
|
- lib/burner/library/collection/nested_aggregate.rb
|