Sha256: f30c62756c0b6d1e7347275fc7e3bd44c746ee7f899373899f3e44e21232ae2a
Contents?: true
Size: 1.11 KB
Versions: 4
Compression:
Stored size: 1.11 KB
Contents
module Foreplay class Engine class Logger INDENT = 4 MARGIN = 24 attr_reader :message, :options def initialize(m, o = {}) @message = m @options = o output end def output puts formatted_message unless silent? end def formatted_message @formatted_message ||= header + message .gsub(/\A\s+/, '') .gsub(/\s+\z/, '') .gsub(/(\r\n|\r|\n)/, "\\1#{margin}") end def header @header ||= (margin_format % header_content[0, margin_width - 1]).white end def header_content @header_content ||= (options[:host] || '') end def margin @margin ||= margin_format % '' end def silent? @silent ||= (options[:silent] == true) || message.blank? end def margin_width @margin_width ||= MARGIN + INDENT * (options[:indent] || 0) end def margin_format @margin_format ||= "%-#{margin_width}s" end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
foreplay-0.11.0 | lib/foreplay/engine/logger.rb |
foreplay-0.10.3 | lib/foreplay/engine/logger.rb |
foreplay-0.10.2 | lib/foreplay/engine/logger.rb |
foreplay-0.10.1 | lib/foreplay/engine/logger.rb |