Class: Romglog::Base
- Inherits:
-
Object
- Object
- Romglog::Base
- Defined in:
- lib/romglog.rb
Constant Summary collapse
- CLEAR =
"\n----\n"
- CMD =
%{git reflog}
Class Method Summary collapse
Class Method Details
.log_cmd ⇒ Object
33 34 35 |
# File 'lib/romglog.rb', line 33 def self.log_cmd @log_cmd ||= [CMD].concat(ARGV).join(' ') end |
.render_line(line) ⇒ Object
49 50 51 52 |
# File 'lib/romglog.rb', line 49 def self.render_line line cols = line.split(' ') (["\e[#{YELLOW}m#{cols.shift}\e[m"] + cols).join(' ') end |
.run ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/romglog.rb', line 37 def self.run rows, cols = `tput lines; tput cols`.scan(/\d+/).map(&:to_i) `#{log_cmd}`.tap {|log| log_lines = Array.new(rows, '') log_lines.unshift(*log.split("\n")) print CLEAR + log_lines[0...(rows - 1)].map {|l| render_line(l) }.join("\n") + "\n" + "\e[#{GREY}mupdated #{Time.now.strftime("%a %H:%M:%S")}\e[m ".rjust(cols + 8) } end |