Module: Kiba::Extend::Jobs::Reporter
- Included in:
- DependencyJob, Runner
- Defined in:
- lib/kiba/extend/jobs/reporter.rb
Overview
Mixin methods for reporting
Instance Method Summary collapse
-
#desc_and_tags ⇒ Object
-
#get_duration ⇒ Object
-
#minimal_end ⇒ Object
silent.
-
#minimal_start ⇒ Object
-
#normal_end ⇒ Object
-
#normal_start ⇒ Object
-
#put_file_details ⇒ Object
-
#report_run_end ⇒ Object
-
#report_run_start ⇒ Object
-
#row_report ⇒ Object
-
#start_and_def ⇒ Object
-
#start_label ⇒ Object
-
#tags ⇒ Object
-
#verbose_end ⇒ Object
-
#verbose_start ⇒ Object
Instance Method Details
#desc_and_tags ⇒ Object
78 79 80 81 82 83 |
# File 'lib/kiba/extend/jobs/reporter.rb', line 78 def parts = [job_data.desc, ].compact return if parts.empty? parts.join(" -- ") end |
#get_duration ⇒ Object
118 119 120 121 122 123 124 125 126 |
# File 'lib/kiba/extend/jobs/reporter.rb', line 118 def get_duration return "" if @dependency minutes = (@duration / 60).floor seconds = (@duration - (minutes * 60)).ceil "#{minutes}m #{seconds}s" rescue "" end |
#minimal_end ⇒ Object
silent
72 73 74 75 76 |
# File 'lib/kiba/extend/jobs/reporter.rb', line 72 def minimal_end puts row_report puts "-=-=-=-=-=-=-=-=-=-=-=-" puts "" end |
#minimal_start ⇒ Object
51 52 53 54 |
# File 'lib/kiba/extend/jobs/reporter.rb', line 51 def minimal_start puts "\n-=-=-=-=-=-=-=-=-=-=-=-" puts start_and_def end |
#normal_end ⇒ Object
64 65 66 67 68 69 |
# File 'lib/kiba/extend/jobs/reporter.rb', line 64 def normal_end puts "\n#{row_report} written to #{job_data.path} in #{get_duration}" puts "NOTE: #{job_data..upcase}" if job_data. puts "-=-=-=-=-=-=-=-=-=-=-=-" puts "" end |
#normal_start ⇒ Object
44 45 46 47 48 49 |
# File 'lib/kiba/extend/jobs/reporter.rb', line 44 def normal_start puts "\n-=-=-=-=-=-=-=-=-=-=-=-" puts start_and_def puts puts "" end |
#put_file_details ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/kiba/extend/jobs/reporter.rb', line 85 def put_file_details puts "SOURCES" @files[:source].each { |src| puts "source #{src.klass} #{src.args}" } puts "DESTINATIONS" @files[:destination].each do |dest| puts "destination #{dest.klass} #{dest.args}" end if @files[:lookup] puts "LOOKUPS" @files[:lookup].each { |lkup| puts "lookup #{lkup.args}" } end puts "" end |
#report_run_end ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/kiba/extend/jobs/reporter.rb', line 22 def report_run_end @duration = Time.now - @start unless @dependency case Kiba::Extend.job_verbosity when :verbose verbose_end nil when :minimal minimal_end nil else normal_end end end |
#report_run_start ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/kiba/extend/jobs/reporter.rb', line 8 def report_run_start @start = Time.now unless @dependency case Kiba::Extend.job_verbosity when :verbose verbose_start nil when :minimal minimal_start nil else normal_start end end |
#row_report ⇒ Object
99 100 101 |
# File 'lib/kiba/extend/jobs/reporter.rb', line 99 def row_report "#{outrows} of #{srcrows}" end |
#start_and_def ⇒ Object
107 108 109 |
# File 'lib/kiba/extend/jobs/reporter.rb', line 107 def start_and_def "#{start_label}: #{job_data.key} -- defined in: #{job_data.creator}" end |
#start_label ⇒ Object
103 104 105 |
# File 'lib/kiba/extend/jobs/reporter.rb', line 103 def start_label @dependency ? "->Starting dependency job" : "Starting job" end |
#tags ⇒ Object
111 112 113 114 115 116 |
# File 'lib/kiba/extend/jobs/reporter.rb', line 111 def = job_data. return unless "tags: [#{.join(", ")}]" end |
#verbose_end ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/kiba/extend/jobs/reporter.rb', line 56 def verbose_end puts "\n#{job_data.key} complete (#{get_duration})" puts "#{row_report} written to #{job_data.path}" puts "NOTE: #{job_data..upcase}" if job_data. puts "-=-=-=-=-=-=-=-=-=-=-=-" puts "" end |
#verbose_start ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/kiba/extend/jobs/reporter.rb', line 36 def verbose_start puts "\n-=-=-=-=-=-=-=-=-=-=-=-" puts start_and_def puts puts "" put_file_details end |