Module: Kuroko2::JobInstancesHelper

Defined in:
app/helpers/kuroko2/job_instances_helper.rb

Instance Method Summary collapse

Instance Method Details

#distance_of_time(from, to) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'app/helpers/kuroko2/job_instances_helper.rb', line 56

def distance_of_time(from, to)
  secs  = (to - from).to_i
  mins  = secs / 60
  hours = mins / 60
  days  = hours / 24

  text = ''
  if days > 0
    text << "#{days}days "
  end

  text << "#{sprintf('%02d', hours % 24)}:#{sprintf('%02d', mins % 60)}:#{sprintf('%02d', secs % 60)}"
  text
end

#first_line(lines) ⇒ Object



52
53
54
# File 'app/helpers/kuroko2/job_instances_helper.rb', line 52

def first_line(lines)
  lines.split("\n").first
end

#labeled_log_level(level) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'app/helpers/kuroko2/job_instances_helper.rb', line 3

def labeled_log_level(level)
  modifier = case level
             when 'INFO'
               'info'
             when 'ERROR'
               'danger'
             when 'WARN'
               'warning'
             else
               'default'
             end
  (:span, level, class: "label label-#{modifier}")
end

#labeled_status(instance) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/helpers/kuroko2/job_instances_helper.rb', line 35

def labeled_status(instance)
  return '--' if instance.nil?
  modifier = case instance.status
             when 'success'
               'success'
             when 'canceled'
               'warning'
             when 'error'
               'danger'
             when 'working'
               'primary'
             else
               'default'
             end
  (:span, instance.status.upcase, class: "label label-#{modifier}")
end

#labeled_token_status(status) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/helpers/kuroko2/job_instances_helper.rb', line 17

def labeled_token_status(status)
  modifier = case status
             when 'working'
               'primary'
             when 'finished'
               'success'
             when 'waiting'
               'warning'
             when 'failure'
               'danger'
             when 'critical'
               'warning'
             else
               'default'
             end
  (:span, status.upcase, class: "label label-#{modifier}")
end