Class: Chronicle::ETL::Job
- Inherits:
-
Object
- Object
- Chronicle::ETL::Job
- Extended by:
- Forwardable
- Defined in:
- lib/chronicle/etl/job.rb
Overview
A runner job
TODO: this can probably be merged with JobDefinition. Not clear where the boundaries are
Instance Attribute Summary collapse
-
#extractor_klass ⇒ Object
Returns the value of attribute extractor_klass.
-
#extractor_options ⇒ Object
Returns the value of attribute extractor_options.
-
#job_definition ⇒ Object
Returns the value of attribute job_definition.
-
#loader_klass ⇒ Object
Returns the value of attribute loader_klass.
-
#loader_options ⇒ Object
Returns the value of attribute loader_options.
-
#name ⇒ Object
(also: #id)
Returns the value of attribute name.
-
#transformer_klasses ⇒ Object
Returns the value of attribute transformer_klasses.
-
#transformer_options ⇒ Object
Returns the value of attribute transformer_options.
Instance Method Summary collapse
-
#initialize(job_definition) {|_self| ... } ⇒ Job
constructor
A new instance of Job.
- #instantiate_extractor ⇒ Object
- #instantiate_loader ⇒ Object
- #instantiate_transformers ⇒ Object
- #save_log? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(job_definition) {|_self| ... } ⇒ Job
Returns a new instance of Job.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/chronicle/etl/job.rb', line 28 def initialize(job_definition) @job_definition = job_definition @name = @job_definition.definition[:name] @extractor_options = @job_definition. @transformer_options = @job_definition. @loader_options = @job_definition. set_continuation if use_continuation? yield self if block_given? end |
Instance Attribute Details
#extractor_klass ⇒ Object
Returns the value of attribute extractor_klass.
16 17 18 |
# File 'lib/chronicle/etl/job.rb', line 16 def extractor_klass @extractor_klass end |
#extractor_options ⇒ Object
Returns the value of attribute extractor_options.
16 17 18 |
# File 'lib/chronicle/etl/job.rb', line 16 def @extractor_options end |
#job_definition ⇒ Object
Returns the value of attribute job_definition.
16 17 18 |
# File 'lib/chronicle/etl/job.rb', line 16 def job_definition @job_definition end |
#loader_klass ⇒ Object
Returns the value of attribute loader_klass.
16 17 18 |
# File 'lib/chronicle/etl/job.rb', line 16 def loader_klass @loader_klass end |
#loader_options ⇒ Object
Returns the value of attribute loader_options.
16 17 18 |
# File 'lib/chronicle/etl/job.rb', line 16 def @loader_options end |
#name ⇒ Object Also known as: id
Returns the value of attribute name.
16 17 18 |
# File 'lib/chronicle/etl/job.rb', line 16 def name @name end |
#transformer_klasses ⇒ Object
Returns the value of attribute transformer_klasses.
16 17 18 |
# File 'lib/chronicle/etl/job.rb', line 16 def transformer_klasses @transformer_klasses end |
#transformer_options ⇒ Object
Returns the value of attribute transformer_options.
16 17 18 |
# File 'lib/chronicle/etl/job.rb', line 16 def @transformer_options end |
Instance Method Details
#instantiate_extractor ⇒ Object
39 40 41 42 |
# File 'lib/chronicle/etl/job.rb', line 39 def instantiate_extractor @extractor_klass = @job_definition.extractor_klass @extractor_klass.new(@extractor_options) end |
#instantiate_loader ⇒ Object
50 51 52 53 |
# File 'lib/chronicle/etl/job.rb', line 50 def instantiate_loader @loader_klass = @job_definition.loader_klass @loader_klass.new(@loader_options) end |
#instantiate_transformers ⇒ Object
44 45 46 47 48 |
# File 'lib/chronicle/etl/job.rb', line 44 def instantiate_transformers @job_definition.transformer_klasses.each_with_index.map do |klass, i| klass.new(@transformer_options[i] || {}) end end |
#save_log? ⇒ Boolean
55 56 57 58 |
# File 'lib/chronicle/etl/job.rb', line 55 def save_log? # TODO: this needs more nuance !id.nil? end |
#to_s ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/chronicle/etl/job.rb', line 60 def to_s output = "Job summary\n".upcase.bold # output = "" output += "#{name}:\n" if name output += "→ Extracting from #{@job_definition.extractor_klass.description}\n" output += (@extractor_options) @job_definition.transformer_klasses.each do |klass| output += "→ Transforming #{klass.description}\n" end # TODO: transformer options output += "→ Loading to #{@job_definition.loader_klass.description}\n" output += (@loader_options) output end |