Module: Kiba::Extend::Jobs::Reporter

Included in:
DependencyJob, Runner
Defined in:
lib/kiba/extend/jobs/reporter.rb

Overview

Mixin methods for reporting

Since:

  • 2.2.0

Instance Method Summary collapse

Instance Method Details

#desc_and_tagsObject

Since:

  • 2.2.0



78
79
80
81
82
83
# File 'lib/kiba/extend/jobs/reporter.rb', line 78

def desc_and_tags
  parts = [job_data.desc, tags].compact
  return if parts.empty?

  parts.join(" -- ")
end

#get_durationObject

Since:

  • 2.2.0



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_endObject

silent

Since:

  • 2.2.0



72
73
74
75
76
# File 'lib/kiba/extend/jobs/reporter.rb', line 72

def minimal_end
  puts row_report
  puts "-=-=-=-=-=-=-=-=-=-=-=-"
  puts ""
end

#minimal_startObject

Since:

  • 2.2.0



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

def minimal_start
  puts "\n-=-=-=-=-=-=-=-=-=-=-=-"
  puts start_and_def
end

#normal_endObject

Since:

  • 2.2.0



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.message.upcase}" if job_data.message
  puts "-=-=-=-=-=-=-=-=-=-=-=-"
  puts ""
end

#normal_startObject

Since:

  • 2.2.0



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 desc_and_tags
  puts ""
end

#put_file_detailsObject

Since:

  • 2.2.0



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_endObject

Since:

  • 2.2.0



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_startObject

Since:

  • 2.2.0



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_reportObject

Since:

  • 2.2.0



99
100
101
# File 'lib/kiba/extend/jobs/reporter.rb', line 99

def row_report
  "#{outrows} of #{srcrows}"
end

#start_and_defObject

Since:

  • 2.2.0



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_labelObject

Since:

  • 2.2.0



103
104
105
# File 'lib/kiba/extend/jobs/reporter.rb', line 103

def start_label
  @dependency ? "->Starting dependency job" : "Starting job"
end

#tagsObject

Since:

  • 2.2.0



111
112
113
114
115
116
# File 'lib/kiba/extend/jobs/reporter.rb', line 111

def tags
  tags = job_data.tags
  return unless tags

  "tags: [#{tags.join(", ")}]"
end

#verbose_endObject

Since:

  • 2.2.0



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.message.upcase}" if job_data.message
  puts "-=-=-=-=-=-=-=-=-=-=-=-"
  puts ""
end

#verbose_startObject

Since:

  • 2.2.0



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 desc_and_tags
  puts ""
  put_file_details
end