Class: PVN::Log::Formatter

Inherits:
ColorFormatter show all
Defined in:
lib/pvn/log/formatter/log_formatter.rb

Overview

a format for log entries

Constant Summary collapse

WIDTHS =
{ 
  :revision     => 10, 
  :neg_revision => 5,
  :pos_revision => 5,
  :author       => 25
}
COLORS =
{
  :revision     => [ :bold ],
  :neg_revision => [ :bold ],
  :pos_revision => [ :bold ],
  :author       => [ :bold, :cyan ],
  :date         => [ :bold, :magenta ],

  :added        => [ :green ],
  :modified     => [ :yellow ],
  :deleted      => [ :red ],
  :renamed      => [ :magenta ],

  :dir          => [ :bold ],
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ColorFormatter

#add_field, #colorize, #pad

Constructor Details

#initialize(use_colors) ⇒ Formatter

Returns a new instance of Formatter.



37
38
39
40
# File 'lib/pvn/log/formatter/log_formatter.rb', line 37

def initialize use_colors
  @use_colors = use_colors
  # should also turn this off if not on a terminal that supports colors ...
end

Instance Attribute Details

#use_colorsObject (readonly)

Returns the value of attribute use_colors.



35
36
37
# File 'lib/pvn/log/formatter/log_formatter.rb', line 35

def use_colors
  @use_colors
end

Instance Method Details

#colors(field) ⇒ Object



46
47
48
# File 'lib/pvn/log/formatter/log_formatter.rb', line 46

def colors field
  use_colors ? COLORS[field] : nil
end

#width(field) ⇒ Object



42
43
44
# File 'lib/pvn/log/formatter/log_formatter.rb', line 42

def width field
  WIDTHS[field]
end