Class: PVN::Log::PathFormatter
- Inherits:
-
Formatter
- Object
- ColorFormatter
- Formatter
- PVN::Log::PathFormatter
- 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
Instance Method Summary collapse
- #format ⇒ Object
-
#initialize(use_colors, paths) ⇒ PathFormatter
constructor
A new instance of PathFormatter.
Methods inherited from Formatter
Methods inherited from ColorFormatter
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
#format ⇒ Object
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 |