burner 1.0.0.pre.alpha.4 → 1.0.0.pre.alpha.5
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 +4 -4
- data/README.md +1 -0
- data/lib/burner/jobs.rb +2 -0
- data/lib/burner/jobs/collection/values.rb +50 -0
- data/lib/burner/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57b5b4290b72962e10ce7ea7244a1dcfb43894cff1d72ef4e0684de4cdea4a35
|
4
|
+
data.tar.gz: 2936c408e7ffa3e1e9883510d890329870d5c1a4c129fef1fb283103568c9508
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f514870aa2b12cc4fc34f3952cabf8c738985dac1a6602c7f41aec3f28b83738991d5cf82d429b62d76b0f3a96b85907e51d0e06db0ce33579d1dc74dc55409e
|
7
|
+
data.tar.gz: 2e9ee10f91bb28eb4d79091ae7106f6da640daaf6b5ac2f77e828e81743dfd55d6baca12a0e376c3be709483fe7a94e0f840f47ed2ecb5031233f4ff9ae7db3a
|
data/README.md
CHANGED
@@ -239,6 +239,7 @@ This library only ships with very basic, rudimentary jobs that are meant to just
|
|
239
239
|
* **collection/shift** [amount]: Remove the first N number of elements from an array.
|
240
240
|
* **collection/transform** [attributes, exclusive, separator]: Iterate over all objects and transform each key per the attribute transformers specifications. If exclusive is set to false then the current object will be overridden/merged. Separator can also be set for key path support. This job uses (Realize)[https://github.com/bluemarblepayroll/realize], which provides its own extendable value-transformation pipeline.
|
241
241
|
* **collection/unpivot** [pivot_set]: Take an array of objects and unpivot specific sets of keys into rows. Under the hood it uses [HashMath's Unpivot class](https://github.com/bluemarblepayroll/hash_math#unpivot-hash-key-coalescence-and-row-extrapolation).
|
242
|
+
* **collection/values** [include_keys]: Take an array of objects and call `#values` on each object. If include_keys is true (it is false by default), then call `#keys` on the first object and inject that as a "header" object.
|
242
243
|
|
243
244
|
#### De-serialization
|
244
245
|
|
data/lib/burner/jobs.rb
CHANGED
@@ -14,6 +14,7 @@ require_relative 'jobs/collection/objects_to_arrays'
|
|
14
14
|
require_relative 'jobs/collection/shift'
|
15
15
|
require_relative 'jobs/collection/transform'
|
16
16
|
require_relative 'jobs/collection/unpivot'
|
17
|
+
require_relative 'jobs/collection/values'
|
17
18
|
require_relative 'jobs/deserialize/csv'
|
18
19
|
require_relative 'jobs/deserialize/json'
|
19
20
|
require_relative 'jobs/deserialize/yaml'
|
@@ -41,6 +42,7 @@ module Burner
|
|
41
42
|
register 'collection/shift', Collection::Shift
|
42
43
|
register 'collection/transform', Collection::Transform
|
43
44
|
register 'collection/unpivot', Collection::Unpivot
|
45
|
+
register 'collection/values', Collection::Values
|
44
46
|
register 'deserialize/csv', Deserialize::Csv
|
45
47
|
register 'deserialize/json', Deserialize::Json
|
46
48
|
register 'deserialize/yaml', Deserialize::Yaml
|
@@ -0,0 +1,50 @@
|
|
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
|
+
class Jobs
|
12
|
+
module Collection
|
13
|
+
# Take an array of objects and call #values on each object.
|
14
|
+
# If include_keys is true (it is false by default), then call #keys on the first
|
15
|
+
# object and inject that as a "header" object.
|
16
|
+
# Expected Payload#value input: array of objects.
|
17
|
+
# Payload#value output: An array of arrays.
|
18
|
+
class Values < Job
|
19
|
+
attr_reader :include_keys
|
20
|
+
|
21
|
+
def initialize(name:, include_keys: false)
|
22
|
+
super(name: name)
|
23
|
+
|
24
|
+
@include_keys = include_keys || false
|
25
|
+
|
26
|
+
freeze
|
27
|
+
end
|
28
|
+
|
29
|
+
def perform(_output, payload)
|
30
|
+
keys = include_keys ? [keys(payload.value&.first)] : []
|
31
|
+
values = (payload.value || []).map { |object| values(object) }
|
32
|
+
|
33
|
+
payload.value = keys + values
|
34
|
+
|
35
|
+
nil
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def keys(object)
|
41
|
+
object.respond_to?(:keys) ? object.keys : []
|
42
|
+
end
|
43
|
+
|
44
|
+
def values(object)
|
45
|
+
object.respond_to?(:values) ? object.values : []
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/burner/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: burner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.pre.alpha.
|
4
|
+
version: 1.0.0.pre.alpha.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Ruggio
|
@@ -229,6 +229,7 @@ files:
|
|
229
229
|
- lib/burner/jobs/collection/transform/attribute.rb
|
230
230
|
- lib/burner/jobs/collection/transform/attribute_renderer.rb
|
231
231
|
- lib/burner/jobs/collection/unpivot.rb
|
232
|
+
- lib/burner/jobs/collection/values.rb
|
232
233
|
- lib/burner/jobs/deserialize/csv.rb
|
233
234
|
- lib/burner/jobs/deserialize/json.rb
|
234
235
|
- lib/burner/jobs/deserialize/yaml.rb
|