Class: PVN::Log::PathFormatter

Inherits:
Formatter show all
Defined in:
lib/pvn/log/formatter/path_formatter.rb

Constant Summary collapse

PATH_ACTIONS =
{
  'M' => :modified,
  'A' => :added,
  'D' => :deleted,
  'R' => :renamed,
  SVNx::Action::MODIFIED => :modified,
  SVNx::Action::ADDED => :added,
  SVNx::Action::DELETED => :deleted,
  # SVNx::Action::RENAMED => :renamed
}

Constants inherited from Formatter

Formatter::COLORS, Formatter::WIDTHS

Instance Attribute Summary

Attributes inherited from Formatter

#use_colors

Instance Method Summary collapse

Methods inherited from Formatter

#colors, #width

Methods inherited from ColorFormatter

#add_field, #colorize, #pad

Constructor Details

#initialize(use_colors, paths) ⇒ PathFormatter

Returns a new instance of PathFormatter.



21
22
23
24
# File 'lib/pvn/log/formatter/path_formatter.rb', line 21

def initialize use_colors, paths
  super use_colors
  @paths = paths
end

Instance Method Details

#formatObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/pvn/log/formatter/path_formatter.rb', line 26

def format
  lines = Array.new
  @paths.sort_by { |path| path.name }.each do |path|
    pstr = "    "
    if field = PATH_ACTIONS[path.action]
      pstr << colorize(path.name, field)
    else
      raise "wtf?: #{path.action.inspect}; #{path.action.class}"
    end

    if path.kind == 'dir'
      pstr = colorize(pstr, :dir)
    end

    lines << pstr
  end
  lines
end