Module: Travis::Mailer::Helper::Build
- Defined in:
- lib/travis/mailer/helper/build.rb
Constant Summary collapse
- ONE_HOUR =
3600
- ONE_MINUTE =
60
Instance Method Summary collapse
-
#duration_in_words(started_at, finished_at) ⇒ Object
1 hour, 10 minutes, and 15 seconds 1 hour, 0 minutes, and 5 seconds 1 minutes and 1 second 15 seconds.
- #hours_part(diff) ⇒ Object
- #minutes_part(diff) ⇒ Object
- #print_build_matrix_summary(matrix) ⇒ Object
- #repository_build_url(options) ⇒ Object
- #seconds_part(diff) ⇒ Object
- #title(build) ⇒ Object
Instance Method Details
#duration_in_words(started_at, finished_at) ⇒ Object
1 hour, 10 minutes, and 15 seconds 1 hour, 0 minutes, and 5 seconds 1 minutes and 1 second 15 seconds
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/travis/mailer/helper/build.rb', line 25 def duration_in_words(started_at, finished_at) # difference in seconds diff = (finished_at - started_at).to_i hours = hours_part(diff) minutes = minutes_part(diff) seconds = seconds_part(diff) time_pieces = [] time_pieces << I18n.t(:'datetime.distance_in_words.hours_exact', :count => hours) if hours > 0 time_pieces << I18n.t(:'datetime.distance_in_words.minutes_exact', :count => minutes) if hours > 0 || minutes > 0 time_pieces << I18n.t(:'datetime.distance_in_words.seconds_exact', :count => seconds) time_pieces.to_sentence end |
#hours_part(diff) ⇒ Object
45 46 47 |
# File 'lib/travis/mailer/helper/build.rb', line 45 def hours_part(diff) diff / ONE_HOUR end |
#minutes_part(diff) ⇒ Object
49 50 51 |
# File 'lib/travis/mailer/helper/build.rb', line 49 def minutes_part(diff) (diff % ONE_HOUR) / ONE_MINUTE end |
#print_build_matrix_summary(matrix) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/travis/mailer/helper/build.rb', line 13 def print_build_matrix_summary(matrix) title = '# RVM Duration Status Build Log' summary_lines = matrix.map do |build| [build.number, build.config["RVM"], build_duration(build.started_at, build.finished_at), build.status, "build.link"] end title end |
#repository_build_url(options) ⇒ Object
5 6 7 |
# File 'lib/travis/mailer/helper/build.rb', line 5 def repository_build_url() [Travis.config.host, [:slug], 'builds', [:id]].join('/') end |
#seconds_part(diff) ⇒ Object
53 54 55 |
# File 'lib/travis/mailer/helper/build.rb', line 53 def seconds_part(diff) diff % ONE_MINUTE end |
#title(build) ⇒ Object
9 10 11 |
# File 'lib/travis/mailer/helper/build.rb', line 9 def title(build) "Build Update for #{build.repository.slug}" end |