class Spirit::Logger

@see github.com/chriseppstein/compass/blob/stable/lib/compass/logger.rb

Constants

ACTION_COLORS
COLORS

Public Instance Methods

record(action, *args) click to toggle source

Record that an action has occurred.

# File lib/spirit/logger.rb, line 17
def record(action, *args)
  msg = ''
  msg << color(ACTION_COLORS[action])
  msg << action_padding(action) + action.to_s
  msg << color(:clear)
  msg << ' ' + args.join(' ')
  info msg
end

Private Instance Methods

action_padding(action) click to toggle source

Adds padding to the left of an action that was performed.

# File lib/spirit/logger.rb, line 33
def action_padding(action)
  ' ' * [(max_action_length - action.to_s.length), 0].max
end
actions() click to toggle source
# File lib/spirit/logger.rb, line 42
def actions
  @actions ||= ACTION_COLORS.keys
end
color(c) click to toggle source
# File lib/spirit/logger.rb, line 28
def color(c)
  (c and code = COLORS[c.to_sym]) ? "\e[#{code}m" : ''
end
max_action_length() click to toggle source

the maximum length of all the actions known to the logger.

# File lib/spirit/logger.rb, line 38
def max_action_length
  @max_action_length ||= actions.reduce(0) { |m, a| [m, a.to_s.length].max }
end