Sha256: 4fab2f8fdb06fe685c5fe30fc860327b280e7c1e30a86346b412ce3ff8e1769a

Contents?: true

Size: 1.48 KB

Versions: 2

Compression:

Stored size: 1.48 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,

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

    extend ClassMethods

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cutter-0.8.1 lib/cutter/colored_outputs.rb
cutter-0.8.0 lib/cutter/colored_outputs.rb