Module: Kiba::Extend::Jobs::DynamicJobable
- Includes:
- DependencyHandleable, Reportable
- Defined in:
- lib/kiba/extend/jobs/dynamic_jobable.rb
Overview
Mixin module for dynamic job classes. Handles dependencies, but run
involves plain old Ruby code, not Kiba transformation logic
Implementation
There must be a source and destination method or reader/accessor
attribute defined in the class.
There must be a job_code method which runs the job logic. This can be
a pointer/wrapper to other methods/classes/etc., but the entire logic
of the job should be encapsulated in this one method call.
Override outrows (and, optionally, srcrows) methods with
appropriate logic for the output format.
Instance Method Summary collapse
-
#destination_key ⇒ Object
-
#destination_path ⇒ Object
-
#files ⇒ Object
-
#outrows ⇒ Object
-
#run ⇒ Object
if caller(2, 5).join(“ “)[“block in handle_requirements”] @dependency = true end extend DependencyJob if @dependency.
-
#source_path ⇒ Object
-
#srcrows ⇒ Object
Methods included from Reportable
#desc_and_tags, #get_duration, #minimal_end, #minimal_start, #normal_end, #normal_start, #put_file_details, #report_run_end, #report_run_start, #row_report, #start_and_def, #start_label, #tags, #verbose_end, #verbose_start
Methods included from DependencyHandleable
#check_requirements, #destinations, #file_config, #handle_requirements, #prep_file, #setup_file_for, #setup_files, #setup_files_for, #setup_source_for, #sources
Instance Method Details
#destination_key ⇒ Object
60 |
# File 'lib/kiba/extend/jobs/dynamic_jobable.rb', line 60 def destination_key = destination |
#destination_path ⇒ Object
56 57 58 |
# File 'lib/kiba/extend/jobs/dynamic_jobable.rb', line 56 def destination_path = Kiba::Extend.registry .resolve(destination) .path |
#files ⇒ Object
24 25 26 27 |
# File 'lib/kiba/extend/jobs/dynamic_jobable.rb', line 24 def files = setup_files({ source: [source].flatten, destination: [destination].flatten }) |
#outrows ⇒ Object
64 |
# File 'lib/kiba/extend/jobs/dynamic_jobable.rb', line 64 def outrows = nil |
#run ⇒ Object
if caller(2, 5).join(“ “)[“block in handle_requirements”] @dependency = true end extend DependencyJob if @dependency
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/kiba/extend/jobs/dynamic_jobable.rb', line 34 def run report_run_start # defined in Reportable # defined in Runnable %i[source lookup].each do |type| handle_requirements(type) end job_code report_run_end # defined in Reportable rescue => err puts "JOB FAILED: TRANSFORM ERROR IN: #{job_data.creator}" puts "#{err.class.name}: #{err.}" puts "AT:" puts err.backtrace.first(10) exit end |
#source_path ⇒ Object
52 53 54 |
# File 'lib/kiba/extend/jobs/dynamic_jobable.rb', line 52 def source_path = Kiba::Extend.registry .resolve(source) &.path |
#srcrows ⇒ Object
62 |
# File 'lib/kiba/extend/jobs/dynamic_jobable.rb', line 62 def srcrows = nil |