Module: Schedulero::Utils
- Included in:
- Schedulero
- Defined in:
- lib/utils.rb
Instance Method Summary collapse
Instance Method Details
#humanize_seconds(secs) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/utils.rb', line 3 def humanize_seconds secs return '-' unless secs secs = secs.to_i [[60, :sec], [60, :min], [24, :h], [356, :days], [1000, :years]].map{ |count, name| if secs > 0 secs, n = secs.divmod(count) "#{n.to_i} #{name}" end }.compact.reverse.slice(0,2).join(' ') end |
#quick_overview(lines: 100) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/utils.rb', line 16 def quick_overview lines: 100 data = ['Tasks:'] for name, task in tasks at = task[:at] ? "at #{task[:at]}" : "every #{humanize_seconds(task[:interval])}" data.push '- %s, %s' % [name, at] end data.push ['','###', ''] data.push `tail -#{lines} #{@log_file}`.split($/).reverse if @log_file data.join($/) end |