class Flexdot::Output
Constants
- Status
Attributes
dotfiles_dir[R]
Public Class Methods
new(dotfiles_dir, colorize: true)
click to toggle source
# File lib/flexdot/output.rb, line 9 def initialize(dotfiles_dir, colorize: true) @dotfiles_dir = dotfiles_dir @colorize = colorize end
Public Instance Methods
log(home_file) { |status| ... }
click to toggle source
# File lib/flexdot/output.rb, line 14 def log(home_file) status = Status.new(home_file) yield(status) puts message_for(status) end
Private Instance Methods
colorize?()
click to toggle source
# File lib/flexdot/output.rb, line 44 def colorize? @colorize end
message_for(status)
click to toggle source
# File lib/flexdot/output.rb, line 24 def message_for(status) result_color = case status.result when :already_linked then :gray when :link_updated then :yellow when :link_created then :green else :default end msg = [] msg << paint("#{status.result.to_s.gsub('_', ' ')}:", result_color) msg << status.home_file.relative_path_from(dotfiles_dir) msg << '(backup)' if status.backuped msg.join(' ') end
paint(string, *colors)
click to toggle source
# File lib/flexdot/output.rb, line 40 def paint(string, *colors) colorize? ? Paint[string, *colors] : string end