Module: Kuroko2::JobInstancesHelper
- Defined in:
- app/helpers/kuroko2/job_instances_helper.rb
Instance Method Summary collapse
- #distance_of_time(from, to) ⇒ Object
- #first_line(lines) ⇒ Object
- #labeled_status(instance) ⇒ Object
- #labeled_token_status(status) ⇒ Object
Instance Method Details
#distance_of_time(from, to) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/helpers/kuroko2/job_instances_helper.rb', line 42 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
38 39 40 |
# File 'app/helpers/kuroko2/job_instances_helper.rb', line 38 def first_line(lines) lines.split("\n").first end |
#labeled_status(instance) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/helpers/kuroko2/job_instances_helper.rb', line 21 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 content_tag(:span, instance.status.upcase, class: "label label-#{modifier}") end |
#labeled_token_status(status) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/helpers/kuroko2/job_instances_helper.rb', line 3 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 content_tag(:span, status.upcase, class: "label label-#{modifier}") end |