burner 1.0.0.pre.alpha.10 → 1.0.0.pre.alpha.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 070f757d857aa8f1e07dd5cdaea5bdd261b050ef343c5f16f2692c6a5ba85eb1
4
- data.tar.gz: 719a284fde5030e3e92fbaebd8c1f91f4445703710b6c00c9e2acf68c108a853
3
+ metadata.gz: adf7e5e1ea0c19d59b6edcbb1c5073e25f533bf32076df4ec7d9122edc852958
4
+ data.tar.gz: 40009afdb93c5ee3971513971dd47a8f416acd04b33eb0c8e9720806cce4a515
5
5
  SHA512:
6
- metadata.gz: bd8938f87808a5c71a64839bc4d6cbc05bdfbb3f8df98a4aba92bbbb1a6163527ff5ba702525ad972a952faf05e35eda39adafe916540b94c775e2a96e71fcc0
7
- data.tar.gz: debd08acef4aa54f88d796a0e217a83477af63d3a82bb7f07123d2360d8b40787e621831ea9d0d58cd39b088684ac6219f23c5aed49d274e39be360cdb16af1a
6
+ metadata.gz: cf255e3021e975451354a3d9537b464ffc61843c59b780ceace9dc6be04e4e2499f5d874aa905608ed3c4b60c4989e6bb3c8cccd2116e8286ca045ea4202bea7
7
+ data.tar.gz: 569a44eb9a5915d946b4de3038ead60094b170481583ea6974391eedaba209162df03883757b917b2e9c3ed3be6d8c2f80f64f43e6420d5fbc2d711eedc81a8c
data/README.md CHANGED
@@ -262,8 +262,8 @@ This library only ships with very basic, rudimentary jobs that are meant to just
262
262
 
263
263
  #### General
264
264
 
265
- * **b/dummy** []: Do nothing
266
265
  * **b/echo** [message]: Write a message to the output. The message parameter can be interpolated using `Payload#params`.
266
+ * **b/nothing** []: Do nothing.
267
267
  * **b/set** [register, value]: Set the value to any arbitrary value.
268
268
  * **b/sleep** [seconds]: Sleep the thread for X number of seconds.
269
269
 
@@ -31,10 +31,11 @@ module Burner
31
31
  # The #perform method takes in two arguments: output (an instance of Burner::Output)
32
32
  # and payload (an instance of Burner::Payload). Jobs can leverage output to emit
33
33
  # information to the pipeline's log(s). The payload is utilized to pass data from job to job,
34
- # with its most important attribute being #value. The value attribute is mutable
35
- # per the individual job's context (meaning of it is unknown without understanding a job's
36
- # input and output value of #value.). Therefore #value can mean anything and it is up to the
37
- # engineers to clearly document the assumptions of its use.
34
+ # with its most important attribute being #registers. The registers attribute is a mutable
35
+ # and accessible hash per the individual job's context
36
+ # (meaning of it is unknown without understanding a job's input and output value
37
+ # of #registers.). Therefore #register key values can mean anything
38
+ # and it is up to consumers to clearly document the assumptions of its use.
38
39
  #
39
40
  # Returning false will short-circuit the pipeline right after the job method exits.
40
41
  # Returning anything else besides false just means "continue".
@@ -47,9 +48,15 @@ module Burner
47
48
  protected
48
49
 
49
50
  def job_string_template(expression, output, payload)
50
- templatable_params = payload.params.merge(__id: output.id, __value: payload[''])
51
+ templatable_params = payload.params
52
+ .merge(__id: output.id)
53
+ .merge(templatable_register_values(payload))
51
54
 
52
55
  Util::StringTemplate.instance.evaluate(expression, templatable_params)
53
56
  end
57
+
58
+ def templatable_register_values(payload)
59
+ payload.registers.transform_keys { |key| "__#{key}_register" }
60
+ end
54
61
  end
55
62
  end
@@ -16,10 +16,10 @@ module Burner
16
16
  class Jobs
17
17
  acts_as_hashable_factory
18
18
 
19
- # Dummy is the default as noted by the ''. This means if a type is omitted, nil, or blank
20
- # string then the dummy job will be used.
21
- register 'b/dummy', '', Library::Dummy
19
+ # Nothing is the default as noted by the ''. This means if a type is omitted, nil, or blank
20
+ # string then the nothing job will be used.
22
21
  register 'b/echo', Library::Echo
22
+ register 'b/nothing', '', Library::Nothing
23
23
  register 'b/set_value', Library::SetValue
24
24
  register 'b/sleep', Library::Sleep
25
25
 
@@ -9,6 +9,11 @@
9
9
 
10
10
  require_relative 'job_with_register'
11
11
 
12
+ require_relative 'library/echo'
13
+ require_relative 'library/nothing'
14
+ require_relative 'library/set_value'
15
+ require_relative 'library/sleep'
16
+
12
17
  require_relative 'library/collection/arrays_to_objects'
13
18
  require_relative 'library/collection/graph'
14
19
  require_relative 'library/collection/objects_to_arrays'
@@ -17,16 +22,15 @@ require_relative 'library/collection/transform'
17
22
  require_relative 'library/collection/unpivot'
18
23
  require_relative 'library/collection/validate'
19
24
  require_relative 'library/collection/values'
25
+
20
26
  require_relative 'library/deserialize/csv'
21
27
  require_relative 'library/deserialize/json'
22
28
  require_relative 'library/deserialize/yaml'
23
- require_relative 'library/dummy'
24
- require_relative 'library/echo'
29
+
25
30
  require_relative 'library/io/exist'
26
31
  require_relative 'library/io/read'
27
32
  require_relative 'library/io/write'
33
+
28
34
  require_relative 'library/serialize/csv'
29
35
  require_relative 'library/serialize/json'
30
36
  require_relative 'library/serialize/yaml'
31
- require_relative 'library/set_value'
32
- require_relative 'library/sleep'
@@ -14,8 +14,8 @@ module Burner
14
14
  # Burner::Modeling::KeyIndexMapping instances or hashable configurations which specifies
15
15
  # the index-to-key mappings to use.
16
16
  #
17
- # Expected Payload#value input: array of arrays.
18
- # Payload#value output: An array of hashes.
17
+ # Expected Payload[register] input: array of arrays.
18
+ # Payload[register] output: An array of hashes.
19
19
  #
20
20
  # An example using a configuration-first pipeline:
21
21
  #
@@ -47,6 +47,11 @@ module Burner
47
47
  # }
48
48
  #
49
49
  # Burner::Pipeline.make(config).execute
50
+ #
51
+ # Given the above example, the expected output would be:
52
+ # [
53
+ # { 'id' => 1, 'name' => 'funky' }
54
+ # ]
50
55
  class ArraysToObjects < JobWithRegister
51
56
  attr_reader :mappings
52
57
 
@@ -13,8 +13,8 @@ module Burner
13
13
  # Take an array of (denormalized) objects and create an object hierarchy from them.
14
14
  # Under the hood it uses Hashematics: https://github.com/bluemarblepayroll/hashematics.
15
15
  #
16
- # Expected Payload#value input: array of objects.
17
- # Payload#value output: An array of objects.
16
+ # Expected Payload[register] input: array of objects.
17
+ # Payload[register] output: An array of objects.
18
18
  class Graph < JobWithRegister
19
19
  attr_reader :key, :groups
20
20
 
@@ -15,39 +15,41 @@ module Burner
15
15
  # Burner::Modeling::KeyIndexMapping instances or hashable configurations which specifies
16
16
  # the key-to-index mappings to use.
17
17
  #
18
- # Expected Payload#value input: array of hashes.
19
- # Payload#value output: An array of arrays.
18
+ # Expected Payload[register] input: array of hashes.
19
+ # Payload[register] output: An array of arrays.
20
20
  #
21
21
  # An example using a configuration-first pipeline:
22
22
  #
23
- # config = {
24
- # jobs: [
25
- # {
26
- # name: 'set',
27
- # type: 'b/set_value',
28
- # value: [
29
- # [1, 'funky']
30
- # ]
31
- # },
32
- # {
33
- # name: 'map',
34
- # type: 'b/collection/objects_to_arrays',
35
- # mappings: [
36
- # { index: 0, key: 'id' },
37
- # { index: 1, key: 'name' }
38
- # ]
39
- # },
40
- # {
41
- # name: 'output',
42
- # type: 'b/echo',
43
- # message: 'value is currently: {__value}'
44
- # },
23
+ # config = {
24
+ # jobs: [
25
+ # {
26
+ # name: 'set',
27
+ # type: 'b/set_value',
28
+ # value: [
29
+ # { 'id' => 1, 'name' => 'funky' }
30
+ # ],
31
+ # register: register
32
+ # },
33
+ # {
34
+ # name: 'map',
35
+ # type: 'b/collection/objects_to_arrays',
36
+ # mappings: [
37
+ # { index: 0, key: 'id' },
38
+ # { index: 1, key: 'name' }
39
+ # ],
40
+ # register: register
41
+ # },
42
+ # {
43
+ # name: 'output',
44
+ # type: 'b/echo',
45
+ # message: 'value is currently: {__value}'
46
+ # },
45
47
  #
46
- # ],
47
- # steps: %w[set map output]
48
- # }
48
+ # ],
49
+ # steps: %w[set map output]
50
+ # }
49
51
  #
50
- # Burner::Pipeline.make(config).execute
52
+ # Burner::Pipeline.make(config).execute
51
53
  class ObjectsToArrays < JobWithRegister
52
54
  attr_reader :mappings
53
55
 
@@ -14,8 +14,8 @@ module Burner
14
14
  # attribute. The initial use case for this was to remove "header" rows from arrays,
15
15
  # like you would expect when parsing CSV files.
16
16
  #
17
- # Expected Payload#value input: nothing.
18
- # Payload#value output: An array with N beginning elements removed.
17
+ # Expected Payload[register] input: nothing.
18
+ # Payload[register] output: An array with N beginning elements removed.
19
19
  class Shift < JobWithRegister
20
20
  DEFAULT_AMOUNT = 0
21
21
 
@@ -18,8 +18,8 @@ module Burner
18
18
  # For more information on the specific contract for attributes, see the
19
19
  # Burner::Modeling::Attribute class.
20
20
  #
21
- # Expected Payload#value input: array of objects.
22
- # Payload#value output: An array of objects.
21
+ # Expected Payload[register] input: array of objects.
22
+ # Payload[register] output: An array of objects.
23
23
  class Transform < JobWithRegister
24
24
  BLANK = ''
25
25
 
@@ -14,8 +14,8 @@ module Burner
14
14
  # Under the hood it uses HashMath's Unpivot class:
15
15
  # https://github.com/bluemarblepayroll/hash_math
16
16
  #
17
- # Expected Payload#value input: array of objects.
18
- # Payload#value output: An array of objects.
17
+ # Expected Payload[register] input: array of objects.
18
+ # Payload[register] output: An array of objects.
19
19
  class Unpivot < JobWithRegister
20
20
  attr_reader :unpivot
21
21
 
@@ -14,8 +14,9 @@ module Burner
14
14
  # of validations. The main register will include the valid objects and the invalid_register
15
15
  # will contain the invalid objects.
16
16
  #
17
- # Expected Payload#value input: array of objects.
18
- # Payload#value output: An array of objects.
17
+ # Expected Payload[register] input: array of objects.
18
+ # Payload[register] output: An array of objects that are valid.
19
+ # Payload[invalid_register] output: An array of objects that are invalid.
19
20
  class Validate < JobWithRegister
20
21
  DEFAULT_INVALID_REGISTER = 'invalid'
21
22
  DEFAULT_JOIN_CHAR = ', '
@@ -14,8 +14,8 @@ module Burner
14
14
  # If include_keys is true (it is false by default), then call #keys on the first
15
15
  # object and inject that as a "header" object.
16
16
  #
17
- # Expected Payload#value input: array of objects.
18
- # Payload#value output: An array of arrays.
17
+ # Expected Payload[register] input: array of objects.
18
+ # Payload[register] output: An array of arrays.
19
19
  class Values < JobWithRegister
20
20
  attr_reader :include_keys
21
21
 
@@ -12,8 +12,8 @@ module Burner
12
12
  module Deserialize
13
13
  # Take a CSV string and de-serialize into object(s).
14
14
  #
15
- # Expected Payload#value input: nothing.
16
- # Payload#value output: an array of arrays. Each inner array represents one data row.
15
+ # Expected Payload[register] input: nothing.
16
+ # Payload[register] output: an array of arrays. Each inner array represents one data row.
17
17
  class Csv < JobWithRegister
18
18
  # This currently only supports returning an array of arrays, including the header row.
19
19
  # In the future this could be extended to offer more customizable options, such as
@@ -12,8 +12,8 @@ module Burner
12
12
  module Deserialize
13
13
  # Take a JSON string and deserialize into object(s).
14
14
  #
15
- # Expected Payload#value input: string of JSON data.
16
- # Payload#value output: anything, as specified by the JSON de-serializer.
15
+ # Expected Payload[register] input: string of JSON data.
16
+ # Payload[register] output: anything, as specified by the JSON de-serializer.
17
17
  class Json < JobWithRegister
18
18
  def perform(_output, payload)
19
19
  payload[register] = JSON.parse(payload[register])
@@ -15,8 +15,8 @@ module Burner
15
15
  # YAML. If you wish to ease this restriction, for example if you have custom serialization
16
16
  # for custom classes, then you can pass in safe: false.
17
17
  #
18
- # Expected Payload#value input: string of YAML data.
19
- # Payload#value output: anything as specified by the YAML de-serializer.
18
+ # Expected Payload[register] input: string of YAML data.
19
+ # Payload[register]output: anything as specified by the YAML de-serializer.
20
20
  class Yaml < JobWithRegister
21
21
  attr_reader :safe
22
22
 
@@ -11,7 +11,7 @@ module Burner
11
11
  module Library
12
12
  # Output a simple message to the output.
13
13
  #
14
- # Note: this does not use Payload#value.
14
+ # Note: this does not use Payload#registers.
15
15
  class Echo < Job
16
16
  attr_reader :message
17
17
 
@@ -15,7 +15,7 @@ module Burner
15
15
  # Check to see if a file exists. If short_circuit is set to true and the file
16
16
  # does not exist then the job will return false and short circuit the pipeline.
17
17
  #
18
- # Note: this does not use Payload#value.
18
+ # Note: this does not use Payload#registers.
19
19
  class Exist < Job
20
20
  attr_reader :path, :short_circuit
21
21
 
@@ -14,8 +14,8 @@ module Burner
14
14
  module IO
15
15
  # Read value from disk.
16
16
  #
17
- # Expected Payload#value input: nothing.
18
- # Payload#value output: contents of the specified file.
17
+ # Expected Payload[register] input: nothing.
18
+ # Payload[register] output: contents of the specified file.
19
19
  class Read < Base
20
20
  attr_reader :binary
21
21
 
@@ -14,8 +14,8 @@ module Burner
14
14
  module IO
15
15
  # Write value to disk.
16
16
  #
17
- # Expected Payload#value input: anything.
18
- # Payload#value output: whatever was passed in.
17
+ # Expected Payload[register] input: anything.
18
+ # Payload[register] output: whatever was passed in.
19
19
  class Write < Base
20
20
  attr_reader :binary
21
21
 
@@ -11,8 +11,8 @@ module Burner
11
11
  module Library
12
12
  # Do nothing.
13
13
  #
14
- # Note: this does not use Payload#value.
15
- class Dummy < Job
14
+ # Note: this does not use Payload#registers.
15
+ class Nothing < Job
16
16
  def perform(_output, _payload); end
17
17
  end
18
18
  end
@@ -12,8 +12,8 @@ module Burner
12
12
  module Serialize
13
13
  # Take an array of arrays and create a CSV.
14
14
  #
15
- # Expected Payload#value input: array of arrays.
16
- # Payload#value output: a serialized CSV string.
15
+ # Expected Payload[register] input: array of arrays.
16
+ # Payload[register] output: a serialized CSV string.
17
17
  class Csv < JobWithRegister
18
18
  def perform(_output, payload)
19
19
  payload[register] = CSV.generate(options) do |csv|
@@ -12,8 +12,8 @@ module Burner
12
12
  module Serialize
13
13
  # Treat value like a Ruby object and serialize it using JSON.
14
14
  #
15
- # Expected Payload#value input: anything.
16
- # Payload#value output: string representing the output of the JSON serializer.
15
+ # Expected Payload[register] input: anything.
16
+ # Payload[register] output: string representing the output of the JSON serializer.
17
17
  class Json < JobWithRegister
18
18
  def perform(_output, payload)
19
19
  payload[register] = payload[register].to_json
@@ -12,8 +12,8 @@ module Burner
12
12
  module Serialize
13
13
  # Treat value like a Ruby object and serialize it using YAML.
14
14
  #
15
- # Expected Payload#value input: anything.
16
- # Payload#value output: string representing the output of the YAML serializer.
15
+ # Expected Payload[register] input: anything.
16
+ # Payload[register] output: string representing the output of the YAML serializer.
17
17
  class Yaml < JobWithRegister
18
18
  def perform(_output, payload)
19
19
  payload[register] = payload[register].to_yaml
@@ -11,8 +11,8 @@ module Burner
11
11
  module Library
12
12
  # Arbitrarily set value
13
13
  #
14
- # Expected Payload#value input: anything.
15
- # Payload#value output: whatever value was specified in this job.
14
+ # Expected Payload[register] input: anything.
15
+ # Payload[register] output: whatever value was specified in this job.
16
16
  class SetValue < JobWithRegister
17
17
  attr_reader :value
18
18
 
@@ -11,7 +11,7 @@ module Burner
11
11
  module Library
12
12
  # Arbitrarily put thread to sleep for X number of seconds
13
13
  #
14
- # Payload#value output: whatever value was specified in this job.
14
+ # Note: this does not use Payload#registers.
15
15
  class Sleep < Job
16
16
  attr_reader :seconds
17
17
 
@@ -10,7 +10,9 @@
10
10
  module Burner
11
11
  module Modeling
12
12
  # Defines a top-level key and the associated transformers for deriving the final value
13
- # to set the key to.
13
+ # to set the key to. The transformers that can be passed in can be any Realize::Transformers
14
+ # subclasses. For more information, see the Realize library at:
15
+ # https://github.com/bluemarblepayroll/realize
14
16
  class Attribute
15
17
  acts_as_hashable
16
18
 
@@ -8,16 +8,22 @@
8
8
  #
9
9
 
10
10
  module Burner
11
- # The input for all Job#perform methods. The main notion of this object is its "value"
12
- # attribute. This is dynamic and weak on purpose and is subject to whatever the Job#perform
13
- # methods decides it is. This definitely adds an order-of-magnitude complexity to this whole
14
- # library and lifecycle, but I am not sure there is any other way around it: trying to build
15
- # a generic, open-ended object pipeline to serve almost any use case.
11
+ # The input for all Job#perform methods. The main notion of this object is its 'registers'
12
+ # attribute. This registers attribute is a key-indifferent hash, accessible on Payload using
13
+ # the brackets setter and getter methods. This is dynamic and weak on purpose and is subject
14
+ # to whatever the Job#perform methods decides it is. This definitely adds an order-of-magnitude
15
+ # complexity to this whole library and lifecycle, but I am not sure there is any other way
16
+ # around it: trying to build a generic, open-ended processing pipeline to serve almost
17
+ # any use case.
16
18
  #
17
19
  # The side_effects attribute can also be utilized as a way for jobs to emit any data in a more
18
20
  # structured/additive manner. The initial use case for this was for Burner's core IO jobs to
19
21
  # report back the files it has written in a more structured data way (as opposed to simply
20
22
  # writing some information to the output.)
23
+ #
24
+ # The 'time' attribute is important in that it should for the replaying of pipelines and jobs.
25
+ # Instead of having job's utilizing Time.now, Date.today, etc... they should rather opt to
26
+ # use this value instead.
21
27
  class Payload
22
28
  attr_reader :params,
23
29
  :registers,
@@ -8,5 +8,5 @@
8
8
  #
9
9
 
10
10
  module Burner
11
- VERSION = '1.0.0-alpha.10'
11
+ VERSION = '1.0.0-alpha.11'
12
12
  end
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.10
4
+ version: 1.0.0.pre.alpha.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Ruggio
@@ -235,12 +235,12 @@ files:
235
235
  - lib/burner/library/deserialize/csv.rb
236
236
  - lib/burner/library/deserialize/json.rb
237
237
  - lib/burner/library/deserialize/yaml.rb
238
- - lib/burner/library/dummy.rb
239
238
  - lib/burner/library/echo.rb
240
239
  - lib/burner/library/io/base.rb
241
240
  - lib/burner/library/io/exist.rb
242
241
  - lib/burner/library/io/read.rb
243
242
  - lib/burner/library/io/write.rb
243
+ - lib/burner/library/nothing.rb
244
244
  - lib/burner/library/serialize/csv.rb
245
245
  - lib/burner/library/serialize/json.rb
246
246
  - lib/burner/library/serialize/yaml.rb