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.

Since:

  • 2.2.0

Instance Method Summary collapse

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_keyObject

Since:

  • 2.2.0



60
# File 'lib/kiba/extend/jobs/dynamic_jobable.rb', line 60

def destination_key = destination

#destination_pathObject

Since:

  • 2.2.0



56
57
58
# File 'lib/kiba/extend/jobs/dynamic_jobable.rb', line 56

def destination_path = Kiba::Extend.registry
.resolve(destination)
.path

#filesObject

Since:

  • 2.2.0



24
25
26
27
# File 'lib/kiba/extend/jobs/dynamic_jobable.rb', line 24

def files = setup_files({
  source: [source].flatten,
  destination: [destination].flatten
})

#outrowsObject

Since:

  • 2.2.0



64
# File 'lib/kiba/extend/jobs/dynamic_jobable.rb', line 64

def outrows = nil

#runObject

if caller(2, 5).join(“ “)[“block in handle_requirements”] @dependency = true end extend DependencyJob if @dependency

Since:

  • 2.2.0



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.message}"
  puts "AT:"
  puts err.backtrace.first(10)
  exit
end

#source_pathObject

Since:

  • 2.2.0



52
53
54
# File 'lib/kiba/extend/jobs/dynamic_jobable.rb', line 52

def source_path = Kiba::Extend.registry
.resolve(source)
&.path

#srcrowsObject

Since:

  • 2.2.0



62
# File 'lib/kiba/extend/jobs/dynamic_jobable.rb', line 62

def srcrows = nil