Sha256: 98de5bb254f1feb4f8e8af8eba178fad2ed981fbd9362b21904b4a83cfc80589

Contents?: true

Size: 1.72 KB

Versions: 3

Compression:

Stored size: 1.72 KB

Contents

require 'colorize'
class Object
  
  def line sp = ""
    log_coloured sp, "------------------------------", color(:line)
  end

  def log_coloured sp, msg, color = :default
    message = sp + msg
    message = color != :default ? message.send(color) : message
    puts message
  end
end

module Cutter
  module ColoredOutputs
    module ClassMethods
      def turn_colors state = :on
        @colors_state = state
      end

      def colors?
        @colors_state ||= :on
        @colors_state == :on
      end

      def colors &block
        yield colors_config
      end

      def colors_config
        @colors ||= {
                      :line => :blue, 
                      :time => :light_blue,

                      :message_name => :cyan,
                      :message_line => :cyan,
                      :total_line => :yellow,
                      :total_count => :yellow,
                     
                      # Colors for #inspect!
                      #  :called_from => :light_magenta,
                      :class_name => :light_green,
                      :method => :red,
                      :method_name => :yellow,
                      # :lv => :blue,
                      # :lv_names => :magenta,
                      # :lv_values => :light_red,
                      # :iv => :cyan,
                      :iv_names => :cyan,
                      :iv_values => :light_blue,
                      :self_inspection => :red,
                      :self_inspection_trace => :blue,
                      :caller_methods => :red,
                      :caller_method => :green
                    }
      end
    end

    extend ClassMethods

    def self.included(base)
      base.extend ClassMethods
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cutter-0.8.5 lib/cutter/colored_outputs.rb
cutter-0.8.4 lib/cutter/colored_outputs.rb
cutter-0.8.3 lib/cutter/colored_outputs.rb