burner 1.0.0.pre.alpha.5 → 1.0.0.pre.alpha.6
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 +12 -12
- data/exe/burner +2 -3
- data/lib/burner.rb +2 -0
- data/lib/burner/cli.rb +2 -0
- data/lib/burner/job.rb +25 -5
- data/lib/burner/jobs.rb +21 -41
- data/lib/burner/library.rb +30 -0
- data/lib/burner/library/collection/arrays_to_objects.rb +77 -0
- data/lib/burner/{jobs → library}/collection/graph.rb +3 -2
- data/lib/burner/{jobs → library}/collection/objects_to_arrays.rb +40 -4
- data/lib/burner/{jobs → library}/collection/shift.rb +5 -4
- data/lib/burner/{jobs → library}/collection/transform.rb +13 -9
- data/lib/burner/{jobs → library}/collection/unpivot.rb +7 -5
- data/lib/burner/{jobs → library}/collection/values.rb +5 -4
- data/lib/burner/{jobs → library}/deserialize/csv.rb +2 -1
- data/lib/burner/{jobs → library}/deserialize/json.rb +4 -1
- data/lib/burner/{jobs → library}/deserialize/yaml.rb +8 -2
- data/lib/burner/{jobs → library}/dummy.rb +3 -1
- data/lib/burner/{jobs → library}/echo.rb +3 -1
- data/lib/burner/{jobs → library}/io/base.rb +1 -1
- data/lib/burner/{jobs → library}/io/exist.rb +3 -1
- data/lib/burner/{jobs → library}/io/read.rb +4 -1
- data/lib/burner/{jobs → library}/io/write.rb +7 -2
- data/lib/burner/{jobs → library}/serialize/csv.rb +3 -2
- data/lib/burner/{jobs → library}/serialize/json.rb +4 -1
- data/lib/burner/{jobs → library}/serialize/yaml.rb +4 -1
- data/lib/burner/{jobs/set.rb → library/set_value.rb} +5 -2
- data/lib/burner/{jobs → library}/sleep.rb +3 -1
- data/lib/burner/modeling.rb +2 -0
- data/lib/burner/modeling/attribute.rb +29 -0
- data/lib/burner/modeling/attribute_renderer.rb +32 -0
- data/lib/burner/payload.rb +15 -12
- data/lib/burner/pipeline.rb +20 -1
- data/lib/burner/side_effects.rb +10 -0
- data/lib/burner/side_effects/written_file.rb +28 -0
- data/lib/burner/util.rb +10 -0
- data/lib/burner/util/arrayable.rb +30 -0
- data/lib/burner/version.rb +1 -1
- metadata +30 -26
- data/lib/burner/jobs/collection/arrays_to_objects.rb +0 -43
- data/lib/burner/jobs/collection/transform/attribute.rb +0 -33
- data/lib/burner/jobs/collection/transform/attribute_renderer.rb +0 -36
- data/lib/burner/written_file.rb +0 -28
data/lib/burner/pipeline.rb
CHANGED
@@ -19,11 +19,16 @@ module Burner
|
|
19
19
|
acts_as_hashable
|
20
20
|
|
21
21
|
class JobNotFoundError < StandardError; end
|
22
|
+
class DuplicateJobNameError < StandardError; end
|
22
23
|
|
23
24
|
attr_reader :steps
|
24
25
|
|
25
26
|
def initialize(jobs: [], steps: [])
|
26
|
-
|
27
|
+
jobs = Jobs.array(jobs)
|
28
|
+
|
29
|
+
assert_unique_job_names(jobs)
|
30
|
+
|
31
|
+
jobs_by_name = jobs.map { |job| [job.name, job] }.to_h
|
27
32
|
|
28
33
|
@steps = Array(steps).map do |step_name|
|
29
34
|
job = jobs_by_name[step_name.to_s]
|
@@ -60,6 +65,20 @@ module Burner
|
|
60
65
|
|
61
66
|
private
|
62
67
|
|
68
|
+
def assert_unique_job_names(jobs)
|
69
|
+
unique_job_names = Set.new
|
70
|
+
|
71
|
+
jobs.each do |job|
|
72
|
+
if unique_job_names.include?(job.name)
|
73
|
+
raise DuplicateJobNameError, "job with name: #{job.name} already declared"
|
74
|
+
end
|
75
|
+
|
76
|
+
unique_job_names << job.name
|
77
|
+
end
|
78
|
+
|
79
|
+
nil
|
80
|
+
end
|
81
|
+
|
63
82
|
def output_params(params, output)
|
64
83
|
if params.keys.any?
|
65
84
|
output.write('Parameters:')
|
@@ -0,0 +1,10 @@
|
|
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 'side_effects/written_file'
|
@@ -0,0 +1,28 @@
|
|
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 SideEffects
|
12
|
+
# Describes a file that was generated by a Job. If a Job emits a file, it should also add the
|
13
|
+
# file details to the Payload#side_effects array using the Payload#add_side_effect method.
|
14
|
+
class WrittenFile
|
15
|
+
attr_reader :logical_filename,
|
16
|
+
:physical_filename,
|
17
|
+
:time_in_seconds
|
18
|
+
|
19
|
+
def initialize(logical_filename:, physical_filename:, time_in_seconds:)
|
20
|
+
@logical_filename = logical_filename.to_s
|
21
|
+
@physical_filename = physical_filename.to_s
|
22
|
+
@time_in_seconds = time_in_seconds.to_f
|
23
|
+
|
24
|
+
freeze
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/burner/util.rb
ADDED
@@ -0,0 +1,10 @@
|
|
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 'util/arrayable'
|
@@ -0,0 +1,30 @@
|
|
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 Util
|
12
|
+
# Provide helper methods for dealing with Arrays.
|
13
|
+
module Arrayable
|
14
|
+
# Since Ruby's Kernel#Array will properly call #to_a for scalar Hash objects, this could
|
15
|
+
# return something funky in the context of this library. In this library, Hash instances
|
16
|
+
# are typically viewed as an atomic key-value-based "object". This library likes to deal
|
17
|
+
# with object-like things, treating Hash, OpenStruct, Struct, or Object subclasses as
|
18
|
+
# basically the same thing. In this vein, this library leverages Objectable to help
|
19
|
+
# unify access data from objects. See the Objectable library for more information:
|
20
|
+
# https://github.com/bluemarblepayroll/objectable
|
21
|
+
def array(value)
|
22
|
+
if value.is_a?(Hash)
|
23
|
+
[value]
|
24
|
+
else
|
25
|
+
Array(value)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
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.0.0.pre.alpha.
|
4
|
+
version: 1.0.0.pre.alpha.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Ruggio
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: acts_as_hashable
|
@@ -221,38 +221,42 @@ files:
|
|
221
221
|
- lib/burner/cli.rb
|
222
222
|
- lib/burner/job.rb
|
223
223
|
- lib/burner/jobs.rb
|
224
|
-
- lib/burner/
|
225
|
-
- lib/burner/
|
226
|
-
- lib/burner/
|
227
|
-
- lib/burner/
|
228
|
-
- lib/burner/
|
229
|
-
- lib/burner/
|
230
|
-
- lib/burner/
|
231
|
-
- lib/burner/
|
232
|
-
- lib/burner/
|
233
|
-
- lib/burner/
|
234
|
-
- lib/burner/
|
235
|
-
- lib/burner/
|
236
|
-
- lib/burner/
|
237
|
-
- lib/burner/
|
238
|
-
- lib/burner/
|
239
|
-
- lib/burner/
|
240
|
-
- lib/burner/
|
241
|
-
- lib/burner/
|
242
|
-
- lib/burner/
|
243
|
-
- lib/burner/
|
244
|
-
- lib/burner/
|
245
|
-
- lib/burner/
|
246
|
-
- lib/burner/jobs/sleep.rb
|
224
|
+
- lib/burner/library.rb
|
225
|
+
- lib/burner/library/collection/arrays_to_objects.rb
|
226
|
+
- lib/burner/library/collection/graph.rb
|
227
|
+
- lib/burner/library/collection/objects_to_arrays.rb
|
228
|
+
- lib/burner/library/collection/shift.rb
|
229
|
+
- lib/burner/library/collection/transform.rb
|
230
|
+
- lib/burner/library/collection/unpivot.rb
|
231
|
+
- lib/burner/library/collection/values.rb
|
232
|
+
- lib/burner/library/deserialize/csv.rb
|
233
|
+
- lib/burner/library/deserialize/json.rb
|
234
|
+
- lib/burner/library/deserialize/yaml.rb
|
235
|
+
- lib/burner/library/dummy.rb
|
236
|
+
- lib/burner/library/echo.rb
|
237
|
+
- lib/burner/library/io/base.rb
|
238
|
+
- lib/burner/library/io/exist.rb
|
239
|
+
- lib/burner/library/io/read.rb
|
240
|
+
- lib/burner/library/io/write.rb
|
241
|
+
- lib/burner/library/serialize/csv.rb
|
242
|
+
- lib/burner/library/serialize/json.rb
|
243
|
+
- lib/burner/library/serialize/yaml.rb
|
244
|
+
- lib/burner/library/set_value.rb
|
245
|
+
- lib/burner/library/sleep.rb
|
247
246
|
- lib/burner/modeling.rb
|
247
|
+
- lib/burner/modeling/attribute.rb
|
248
|
+
- lib/burner/modeling/attribute_renderer.rb
|
248
249
|
- lib/burner/modeling/key_index_mapping.rb
|
249
250
|
- lib/burner/output.rb
|
250
251
|
- lib/burner/payload.rb
|
251
252
|
- lib/burner/pipeline.rb
|
253
|
+
- lib/burner/side_effects.rb
|
254
|
+
- lib/burner/side_effects/written_file.rb
|
252
255
|
- lib/burner/step.rb
|
253
256
|
- lib/burner/string_template.rb
|
257
|
+
- lib/burner/util.rb
|
258
|
+
- lib/burner/util/arrayable.rb
|
254
259
|
- lib/burner/version.rb
|
255
|
-
- lib/burner/written_file.rb
|
256
260
|
homepage: https://github.com/bluemarblepayroll/burner
|
257
261
|
licenses:
|
258
262
|
- MIT
|
@@ -1,43 +0,0 @@
|
|
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
|
-
# Convert an array of arrays to an array of objects.
|
14
|
-
# Expected Payload#value input: array of arrays.
|
15
|
-
# Payload#value output: An array of hashes.
|
16
|
-
class ArraysToObjects < Job
|
17
|
-
attr_reader :mappings
|
18
|
-
|
19
|
-
def initialize(name:, mappings: [])
|
20
|
-
super(name: name)
|
21
|
-
|
22
|
-
@mappings = Modeling::KeyIndexMapping.array(mappings)
|
23
|
-
|
24
|
-
freeze
|
25
|
-
end
|
26
|
-
|
27
|
-
def perform(_output, payload)
|
28
|
-
payload.value = (payload.value || []).map { |array| index_to_key_map(array) }
|
29
|
-
|
30
|
-
nil
|
31
|
-
end
|
32
|
-
|
33
|
-
private
|
34
|
-
|
35
|
-
def index_to_key_map(array)
|
36
|
-
mappings.each_with_object({}) do |mapping, memo|
|
37
|
-
memo[mapping.key] = array[mapping.index]
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,33 +0,0 @@
|
|
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
|
-
class Transform < Job
|
14
|
-
# Defines a top-level key and the associated transformers for deriving the final value
|
15
|
-
# to set the key to.
|
16
|
-
class Attribute
|
17
|
-
acts_as_hashable
|
18
|
-
|
19
|
-
attr_reader :key, :transformers
|
20
|
-
|
21
|
-
def initialize(key:, transformers: [])
|
22
|
-
raise ArgumentError, 'key is required' if key.to_s.empty?
|
23
|
-
|
24
|
-
@key = key.to_s
|
25
|
-
@transformers = Realize::Transformers.array(transformers)
|
26
|
-
|
27
|
-
freeze
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,36 +0,0 @@
|
|
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
|
-
class Transform < Job
|
14
|
-
# Composed of an Attribute instance and a Pipeline instance. It knows how to
|
15
|
-
# render/transform an Attribute. Since this library is data-first, these intermediary
|
16
|
-
# objects are necessary for non-data-centric modeling.
|
17
|
-
class AttributeRenderer
|
18
|
-
extend Forwardable
|
19
|
-
|
20
|
-
attr_reader :attribute, :pipeline
|
21
|
-
|
22
|
-
def_delegators :attribute, :key
|
23
|
-
|
24
|
-
def_delegators :pipeline, :transform
|
25
|
-
|
26
|
-
def initialize(attribute, resolver)
|
27
|
-
@attribute = attribute
|
28
|
-
@pipeline = Realize::Pipeline.new(attribute.transformers, resolver: resolver)
|
29
|
-
|
30
|
-
freeze
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
data/lib/burner/written_file.rb
DELETED
@@ -1,28 +0,0 @@
|
|
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
|
-
# Describes a file that was generated by a Job. If a Job emits a file, it should also add the
|
12
|
-
# file details to the Payload#written_files array using the Payload#add_written_file method.
|
13
|
-
class WrittenFile
|
14
|
-
acts_as_hashable
|
15
|
-
|
16
|
-
attr_reader :logical_filename,
|
17
|
-
:physical_filename,
|
18
|
-
:time_in_seconds
|
19
|
-
|
20
|
-
def initialize(logical_filename:, physical_filename:, time_in_seconds:)
|
21
|
-
@logical_filename = logical_filename.to_s
|
22
|
-
@physical_filename = physical_filename.to_s
|
23
|
-
@time_in_seconds = time_in_seconds.to_f
|
24
|
-
|
25
|
-
freeze
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|