Sha256: 0d4d0cf8bc338431cb7e17df3225646dc138ae0e87eae8c2f2e79c4d2abf8b78

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

$:.unshift(File.dirname(__FILE__)) unless
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))

require 'pp'
require 'yaml'
require 'logger'
require 'stringio'
require 'lucid/platform'
require 'lucid/context_loader'
require 'lucid/cli/app'
require 'lucid/step_definitions'
require 'lucid/ansicolor'

module Lucid
  class << self
    attr_accessor :wants_to_quit

    def version
      "Lucid v#{Lucid::VERSION}"
    end

    def breakdown(*args)
      current_output = $stdout
      begin
        msg_string = StringIO.new
        $stdout = msg_string
        pp(*args)
      ensure
        $stdout = current_output
      end
      msg_string.string
    end

    def logger
      return @log if @log
      @log = Logger.new(STDOUT)
      @log.level = Logger::INFO
      @log
    end

    def logger=(logger)
      @log = logger
    end
  end

  class LogFormatter < ::Logger::Formatter
    def call(severity, time, progname, msg)
      if msg.is_a?(String)
        "\n[ LUCID (#{severity}) ] #{msg}\n"
      else
        msg = Lucid.breakdown(msg)
        "\n[ LUCID (#{severity}) ] \n#{msg}\n"
      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lucid-0.5.1 lib/lucid.rb