Class: Compass::Logger
- Inherits:
-
Object
- Object
- Compass::Logger
- Defined in:
- lib/compass/logger.rb
Constant Summary collapse
- DEFAULT_ACTIONS =
[:directory, :exists, :remove, :create, :overwrite, :compile]
Instance Attribute Summary collapse
-
#actions ⇒ Object
Returns the value of attribute actions.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#action_padding(action) ⇒ Object
add padding to the left of an action that was performed.
-
#initialize(*actions) ⇒ Logger
constructor
A new instance of Logger.
-
#log(msg) ⇒ Object
Emit a log message.
-
#max_action_length ⇒ Object
the maximum length of all the actions known to the logger.
-
#record(action, *arguments) ⇒ Object
Record an action that has occurred.
Constructor Details
#initialize(*actions) ⇒ Logger
Returns a new instance of Logger.
8 9 10 11 12 |
# File 'lib/compass/logger.rb', line 8 def initialize(*actions) self. = actions.last.is_a?(Hash) ? actions.pop : {} @actions = DEFAULT_ACTIONS.dup @actions += actions end |
Instance Attribute Details
#actions ⇒ Object
Returns the value of attribute actions.
6 7 8 |
# File 'lib/compass/logger.rb', line 6 def actions @actions end |
#options ⇒ Object
Returns the value of attribute options.
6 7 8 |
# File 'lib/compass/logger.rb', line 6 def @options end |
Instance Method Details
#action_padding(action) ⇒ Object
add padding to the left of an action that was performed.
25 26 27 |
# File 'lib/compass/logger.rb', line 25 def action_padding(action) ' ' * [(max_action_length - action.to_s.length), 0].max end |
#log(msg) ⇒ Object
Emit a log message
20 21 22 |
# File 'lib/compass/logger.rb', line 20 def log(msg) puts msg end |
#max_action_length ⇒ Object
the maximum length of all the actions known to the logger.
30 31 32 |
# File 'lib/compass/logger.rb', line 30 def max_action_length @max_action_length ||= actions.inject(0){|memo, a| [memo, a.to_s.length].max} end |
#record(action, *arguments) ⇒ Object
Record an action that has occurred
15 16 17 |
# File 'lib/compass/logger.rb', line 15 def record(action, *arguments) log "#{action_padding(action)}#{action} #{arguments.join(' ')}" end |