Sha256: 0ffc80f8b0a99d77e27705de92f6819181a136e688e636d1a99146f4d596e1fc

Contents?: true

Size: 898 Bytes

Versions: 21

Compression:

Stored size: 898 Bytes

Contents

module Compass
  class Logger

    DEFAULT_ACTIONS = [:directory, :exists, :remove, :create, :overwrite, :compile]

    attr_accessor :actions, :options

    def initialize(*actions)
      self.options = actions.last.is_a?(Hash) ? actions.pop : {}
      @actions = DEFAULT_ACTIONS.dup
      @actions += actions
    end

    # Record an action that has occurred
    def record(action, *arguments)
      log "#{action_padding(action)}#{action} #{arguments.join(' ')}"
    end

    # Emit a log message
    def log(msg)
      puts msg
    end

    # add padding to the left of an action that was performed.
    def action_padding(action)
      ' ' * [(max_action_length - action.to_s.length), 0].max
    end

    # the maximum length of all the actions known to the logger.
    def max_action_length
      @max_action_length ||= actions.inject(0){|memo, a| [memo, a.to_s.length].max}
    end
  end
end

Version data entries

21 entries across 21 versions & 5 rubygems

Version Path
bsherman-compass-0.5.2 lib/compass/logger.rb
chriseppstein-compass-0.4.0 lib/compass/logger.rb
chriseppstein-compass-0.4.1 lib/compass/logger.rb
chriseppstein-compass-0.4.2 lib/compass/logger.rb
chriseppstein-compass-0.5.0 lib/compass/logger.rb
chriseppstein-compass-0.5.1 lib/compass/logger.rb
chriseppstein-compass-0.5.2 lib/compass/logger.rb
chriseppstein-compass-0.5.3 lib/compass/logger.rb
chriseppstein-compass-0.5.4 lib/compass/logger.rb
chriseppstein-compass-0.5.5 lib/compass/logger.rb
chriseppstein-compass-0.5.9 lib/compass/logger.rb
chriseppstein-compass-0.6.0 lib/compass/logger.rb
chriseppstein-compass-0.6.1 lib/compass/logger.rb
chriseppstein-compass-0.6.2 lib/compass/logger.rb
chriseppstein-compass-0.6.3 lib/compass/logger.rb
chriseppstein-compass-0.6.4 lib/compass/logger.rb
chriseppstein-compass-0.6.5 lib/compass/logger.rb
jsmestad-compass-0.4.2.1 lib/compass/logger.rb
jwhitmire-compass-0.5.1.1 lib/compass/logger.rb
jwhitmire-compass-0.5.1.2 lib/compass/logger.rb