rainbow 2.1.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/Changelog.md +64 -36
- data/README.markdown +67 -175
- metadata +17 -51
- data/.gitignore +0 -17
- data/.rubocop.yml +0 -14
- data/.travis.yml +0 -11
- data/Gemfile +0 -23
- data/Guardfile +0 -9
- data/Rakefile +0 -6
- data/lib/rainbow/color.rb +0 -135
- data/lib/rainbow/ext/string.rb +0 -52
- data/lib/rainbow/global.rb +0 -21
- data/lib/rainbow/legacy.rb +0 -15
- data/lib/rainbow/null_presenter.rb +0 -30
- data/lib/rainbow/presenter.rb +0 -124
- data/lib/rainbow/string_utils.rb +0 -20
- data/lib/rainbow/version.rb +0 -3
- data/lib/rainbow/wrapper.rb +0 -22
- data/lib/rainbow/x11_color_names.rb +0 -152
- data/lib/rainbow.rb +0 -25
- data/rainbow.gemspec +0 -23
- data/spec/integration/instance_spec.rb +0 -35
- data/spec/integration/rainbow_spec.rb +0 -149
- data/spec/integration/string_spec.rb +0 -80
- data/spec/spec_helper.rb +0 -6
- data/spec/support/presenter_shared_examples.rb +0 -9
- data/spec/unit/color_spec.rb +0 -301
- data/spec/unit/namespace_spec.rb +0 -31
- data/spec/unit/null_presenter_spec.rb +0 -93
- data/spec/unit/presenter_spec.rb +0 -168
- data/spec/unit/string_utils_spec.rb +0 -62
- data/spec/unit/wrapper_spec.rb +0 -34
    
        data/lib/rainbow/color.rb
    DELETED
    
    | @@ -1,135 +0,0 @@ | |
| 1 | 
            -
            module Rainbow
         | 
| 2 | 
            -
              class Color
         | 
| 3 | 
            -
             | 
| 4 | 
            -
                attr_reader :ground
         | 
| 5 | 
            -
             | 
| 6 | 
            -
                def self.build(ground, values)
         | 
| 7 | 
            -
                  unless [1, 3].include?(values.size)
         | 
| 8 | 
            -
                    fail ArgumentError,
         | 
| 9 | 
            -
                      "Wrong number of arguments for color definition, should be 1 or 3"
         | 
| 10 | 
            -
                  end
         | 
| 11 | 
            -
             | 
| 12 | 
            -
                  color = values.size == 1 ? values.first : values
         | 
| 13 | 
            -
             | 
| 14 | 
            -
                  case color
         | 
| 15 | 
            -
                  when Fixnum
         | 
| 16 | 
            -
                    Indexed.new(ground, color)
         | 
| 17 | 
            -
                  when Symbol
         | 
| 18 | 
            -
                    if Named.color_names.include?(color)
         | 
| 19 | 
            -
                      Named.new(ground, color)
         | 
| 20 | 
            -
                    else X11Named.color_names.include?(color)
         | 
| 21 | 
            -
                      X11Named.new(ground, color)
         | 
| 22 | 
            -
                    end
         | 
| 23 | 
            -
                  when Array
         | 
| 24 | 
            -
                    RGB.new(ground, *color)
         | 
| 25 | 
            -
                  when String
         | 
| 26 | 
            -
                    RGB.new(ground, *parse_hex_color(color))
         | 
| 27 | 
            -
                  end
         | 
| 28 | 
            -
                end
         | 
| 29 | 
            -
             | 
| 30 | 
            -
                def self.parse_hex_color(hex)
         | 
| 31 | 
            -
                  hex = hex.sub(/^#/, '')
         | 
| 32 | 
            -
                  r   = hex[0..1].to_i(16)
         | 
| 33 | 
            -
                  g   = hex[2..3].to_i(16)
         | 
| 34 | 
            -
                  b   = hex[4..5].to_i(16)
         | 
| 35 | 
            -
             | 
| 36 | 
            -
                  [r, g, b]
         | 
| 37 | 
            -
                end
         | 
| 38 | 
            -
             | 
| 39 | 
            -
                class Indexed < Color
         | 
| 40 | 
            -
             | 
| 41 | 
            -
                  attr_reader :num
         | 
| 42 | 
            -
             | 
| 43 | 
            -
                  def initialize(ground, num)
         | 
| 44 | 
            -
                    @ground = ground
         | 
| 45 | 
            -
                    @num = num
         | 
| 46 | 
            -
                  end
         | 
| 47 | 
            -
             | 
| 48 | 
            -
                  def codes
         | 
| 49 | 
            -
                    code = num + (ground == :foreground ? 30 : 40)
         | 
| 50 | 
            -
             | 
| 51 | 
            -
                    [code]
         | 
| 52 | 
            -
                  end
         | 
| 53 | 
            -
             | 
| 54 | 
            -
                end
         | 
| 55 | 
            -
             | 
| 56 | 
            -
                class Named < Indexed
         | 
| 57 | 
            -
             | 
| 58 | 
            -
                  NAMES = {
         | 
| 59 | 
            -
                    black:   0,
         | 
| 60 | 
            -
                    red:     1,
         | 
| 61 | 
            -
                    green:   2,
         | 
| 62 | 
            -
                    yellow:  3,
         | 
| 63 | 
            -
                    blue:    4,
         | 
| 64 | 
            -
                    magenta: 5,
         | 
| 65 | 
            -
                    cyan:    6,
         | 
| 66 | 
            -
                    white:   7,
         | 
| 67 | 
            -
                    default: 9,
         | 
| 68 | 
            -
                  }
         | 
| 69 | 
            -
             | 
| 70 | 
            -
                  def self.color_names
         | 
| 71 | 
            -
                    NAMES.keys
         | 
| 72 | 
            -
                  end
         | 
| 73 | 
            -
             | 
| 74 | 
            -
                  def initialize(ground, name)
         | 
| 75 | 
            -
                    unless Named.color_names.include?(name)
         | 
| 76 | 
            -
                      fail ArgumentError,
         | 
| 77 | 
            -
                        "Unknown color name, valid names: #{Named.color_names.join(', ')}"
         | 
| 78 | 
            -
                    end
         | 
| 79 | 
            -
             | 
| 80 | 
            -
                    super(ground, NAMES[name])
         | 
| 81 | 
            -
                  end
         | 
| 82 | 
            -
             | 
| 83 | 
            -
                end
         | 
| 84 | 
            -
             | 
| 85 | 
            -
                class RGB < Indexed
         | 
| 86 | 
            -
             | 
| 87 | 
            -
                  attr_reader :r, :g, :b
         | 
| 88 | 
            -
             | 
| 89 | 
            -
                  def self.to_ansi_domain(value)
         | 
| 90 | 
            -
                    (6 * (value / 256.0)).to_i
         | 
| 91 | 
            -
                  end
         | 
| 92 | 
            -
             | 
| 93 | 
            -
                  def initialize(ground, *values)
         | 
| 94 | 
            -
                    if values.min < 0 || values.max > 255
         | 
| 95 | 
            -
                      fail ArgumentError, "RGB value outside 0-255 range"
         | 
| 96 | 
            -
                    end
         | 
| 97 | 
            -
             | 
| 98 | 
            -
                    super(ground, 8)
         | 
| 99 | 
            -
                    @r, @g, @b = values
         | 
| 100 | 
            -
                  end
         | 
| 101 | 
            -
             | 
| 102 | 
            -
                  def codes
         | 
| 103 | 
            -
                    super + [5, code_from_rgb]
         | 
| 104 | 
            -
                  end
         | 
| 105 | 
            -
             | 
| 106 | 
            -
                  private
         | 
| 107 | 
            -
             | 
| 108 | 
            -
                  def code_from_rgb
         | 
| 109 | 
            -
                    16 + self.class.to_ansi_domain(r) * 36 +
         | 
| 110 | 
            -
                         self.class.to_ansi_domain(g) * 6  +
         | 
| 111 | 
            -
                         self.class.to_ansi_domain(b)
         | 
| 112 | 
            -
                  end
         | 
| 113 | 
            -
             | 
| 114 | 
            -
                end
         | 
| 115 | 
            -
             | 
| 116 | 
            -
                class X11Named < RGB
         | 
| 117 | 
            -
                  include X11ColorNames
         | 
| 118 | 
            -
             | 
| 119 | 
            -
                  def self.color_names
         | 
| 120 | 
            -
                    NAMES.keys
         | 
| 121 | 
            -
                  end
         | 
| 122 | 
            -
             | 
| 123 | 
            -
                  def initialize(ground, name)
         | 
| 124 | 
            -
                    unless X11Named.color_names.include?(name)
         | 
| 125 | 
            -
                      fail ArgumentError,
         | 
| 126 | 
            -
                        "Unknown color name, valid names: #{X11Named.color_names.join(', ')}"
         | 
| 127 | 
            -
                    end
         | 
| 128 | 
            -
             | 
| 129 | 
            -
                    super(ground, *NAMES[name])
         | 
| 130 | 
            -
                  end
         | 
| 131 | 
            -
             | 
| 132 | 
            -
                end
         | 
| 133 | 
            -
             | 
| 134 | 
            -
              end
         | 
| 135 | 
            -
            end
         | 
    
        data/lib/rainbow/ext/string.rb
    DELETED
    
    | @@ -1,52 +0,0 @@ | |
| 1 | 
            -
            require 'rainbow'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            module Rainbow
         | 
| 4 | 
            -
              module Ext
         | 
| 5 | 
            -
                module String
         | 
| 6 | 
            -
                  module InstanceMethods
         | 
| 7 | 
            -
             | 
| 8 | 
            -
                    def foreground(*color)
         | 
| 9 | 
            -
                      Rainbow(self).foreground(*color)
         | 
| 10 | 
            -
                    end
         | 
| 11 | 
            -
             | 
| 12 | 
            -
                    alias_method :color, :foreground
         | 
| 13 | 
            -
                    alias_method :colour, :foreground
         | 
| 14 | 
            -
             | 
| 15 | 
            -
                    def background(*color)
         | 
| 16 | 
            -
                      Rainbow(self).background(*color)
         | 
| 17 | 
            -
                    end
         | 
| 18 | 
            -
             | 
| 19 | 
            -
                    def reset
         | 
| 20 | 
            -
                      Rainbow(self).reset
         | 
| 21 | 
            -
                    end
         | 
| 22 | 
            -
             | 
| 23 | 
            -
                    def bright
         | 
| 24 | 
            -
                      Rainbow(self).bright
         | 
| 25 | 
            -
                    end
         | 
| 26 | 
            -
             | 
| 27 | 
            -
                    def italic
         | 
| 28 | 
            -
                      Rainbow(self).italic
         | 
| 29 | 
            -
                    end
         | 
| 30 | 
            -
             | 
| 31 | 
            -
                    def underline
         | 
| 32 | 
            -
                      Rainbow(self).underline
         | 
| 33 | 
            -
                    end
         | 
| 34 | 
            -
             | 
| 35 | 
            -
                    def blink
         | 
| 36 | 
            -
                      Rainbow(self).blink
         | 
| 37 | 
            -
                    end
         | 
| 38 | 
            -
             | 
| 39 | 
            -
                    def inverse
         | 
| 40 | 
            -
                      Rainbow(self).inverse
         | 
| 41 | 
            -
                    end
         | 
| 42 | 
            -
             | 
| 43 | 
            -
                    def hide
         | 
| 44 | 
            -
                      Rainbow(self).hide
         | 
| 45 | 
            -
                    end
         | 
| 46 | 
            -
             | 
| 47 | 
            -
                  end
         | 
| 48 | 
            -
                end
         | 
| 49 | 
            -
              end
         | 
| 50 | 
            -
            end
         | 
| 51 | 
            -
             | 
| 52 | 
            -
            ::String.send(:include, Rainbow::Ext::String::InstanceMethods)
         | 
    
        data/lib/rainbow/global.rb
    DELETED
    
    | @@ -1,21 +0,0 @@ | |
| 1 | 
            -
            require_relative 'wrapper'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            module Rainbow
         | 
| 4 | 
            -
             | 
| 5 | 
            -
              def self.global
         | 
| 6 | 
            -
                @global ||= Wrapper.new
         | 
| 7 | 
            -
              end
         | 
| 8 | 
            -
             | 
| 9 | 
            -
              def self.enabled
         | 
| 10 | 
            -
                global.enabled
         | 
| 11 | 
            -
              end
         | 
| 12 | 
            -
             | 
| 13 | 
            -
              def self.enabled=(value)
         | 
| 14 | 
            -
                global.enabled = value
         | 
| 15 | 
            -
              end
         | 
| 16 | 
            -
             | 
| 17 | 
            -
            end
         | 
| 18 | 
            -
             | 
| 19 | 
            -
            def Rainbow(string)
         | 
| 20 | 
            -
              Rainbow.global.wrap(string.to_s)
         | 
| 21 | 
            -
            end
         | 
    
        data/lib/rainbow/legacy.rb
    DELETED
    
    | @@ -1,15 +0,0 @@ | |
| 1 | 
            -
            module Sickill
         | 
| 2 | 
            -
              module Rainbow
         | 
| 3 | 
            -
             | 
| 4 | 
            -
                def self.enabled=(value)
         | 
| 5 | 
            -
                  STDERR.puts("Rainbow gem notice: Sickill::Rainbow.enabled= is " \
         | 
| 6 | 
            -
                              "deprecated, use Rainbow.enabled= instead.")
         | 
| 7 | 
            -
                  ::Rainbow.enabled = value
         | 
| 8 | 
            -
                end
         | 
| 9 | 
            -
             | 
| 10 | 
            -
                def self.enabled
         | 
| 11 | 
            -
                  ::Rainbow.enabled
         | 
| 12 | 
            -
                end
         | 
| 13 | 
            -
             | 
| 14 | 
            -
              end
         | 
| 15 | 
            -
            end
         | 
| @@ -1,30 +0,0 @@ | |
| 1 | 
            -
            module Rainbow
         | 
| 2 | 
            -
             | 
| 3 | 
            -
              class NullPresenter < ::String
         | 
| 4 | 
            -
             | 
| 5 | 
            -
                def color(*values); self; end
         | 
| 6 | 
            -
                def background(*values); self; end
         | 
| 7 | 
            -
                def reset; self; end
         | 
| 8 | 
            -
                def bright; self; end
         | 
| 9 | 
            -
                def italic; self; end
         | 
| 10 | 
            -
                def underline; self; end
         | 
| 11 | 
            -
                def blink; self; end
         | 
| 12 | 
            -
                def inverse; self; end
         | 
| 13 | 
            -
                def hide; self; end
         | 
| 14 | 
            -
             | 
| 15 | 
            -
                def black; self; end
         | 
| 16 | 
            -
                def red; self; end
         | 
| 17 | 
            -
                def green; self; end
         | 
| 18 | 
            -
                def yellow; self; end
         | 
| 19 | 
            -
                def blue; self; end
         | 
| 20 | 
            -
                def magenta; self; end
         | 
| 21 | 
            -
                def cyan; self; end
         | 
| 22 | 
            -
                def white; self; end
         | 
| 23 | 
            -
             | 
| 24 | 
            -
                alias_method :foreground, :color
         | 
| 25 | 
            -
                alias_method :fg, :color
         | 
| 26 | 
            -
                alias_method :bg, :background
         | 
| 27 | 
            -
             | 
| 28 | 
            -
              end
         | 
| 29 | 
            -
             | 
| 30 | 
            -
            end
         | 
    
        data/lib/rainbow/presenter.rb
    DELETED
    
    | @@ -1,124 +0,0 @@ | |
| 1 | 
            -
            require_relative 'string_utils'
         | 
| 2 | 
            -
            require_relative 'x11_color_names'
         | 
| 3 | 
            -
            require_relative 'color'
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            module Rainbow
         | 
| 6 | 
            -
             | 
| 7 | 
            -
              class Presenter < ::String
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                TERM_EFFECTS = {
         | 
| 10 | 
            -
                  reset:     0,
         | 
| 11 | 
            -
                  bright:    1,
         | 
| 12 | 
            -
                  italic:    3,
         | 
| 13 | 
            -
                  underline: 4,
         | 
| 14 | 
            -
                  blink:     5,
         | 
| 15 | 
            -
                  inverse:   7,
         | 
| 16 | 
            -
                  hide:      8,
         | 
| 17 | 
            -
                }
         | 
| 18 | 
            -
             | 
| 19 | 
            -
                # Sets color of this text.
         | 
| 20 | 
            -
                def color(*values)
         | 
| 21 | 
            -
                  wrap_with_sgr(Color.build(:foreground, values).codes)
         | 
| 22 | 
            -
                end
         | 
| 23 | 
            -
             | 
| 24 | 
            -
                alias_method :foreground, :color
         | 
| 25 | 
            -
                alias_method :fg, :color
         | 
| 26 | 
            -
             | 
| 27 | 
            -
                # Sets background color of this text.
         | 
| 28 | 
            -
                def background(*values)
         | 
| 29 | 
            -
                  wrap_with_sgr(Color.build(:background, values).codes)
         | 
| 30 | 
            -
                end
         | 
| 31 | 
            -
             | 
| 32 | 
            -
                alias_method :bg, :background
         | 
| 33 | 
            -
             | 
| 34 | 
            -
                # Resets terminal to default colors/backgrounds.
         | 
| 35 | 
            -
                #
         | 
| 36 | 
            -
                # It shouldn't be needed to use this method because all methods
         | 
| 37 | 
            -
                # append terminal reset code to end of string.
         | 
| 38 | 
            -
                def reset
         | 
| 39 | 
            -
                  wrap_with_sgr(TERM_EFFECTS[:reset])
         | 
| 40 | 
            -
                end
         | 
| 41 | 
            -
             | 
| 42 | 
            -
                # Turns on bright/bold for this text.
         | 
| 43 | 
            -
                def bright
         | 
| 44 | 
            -
                  wrap_with_sgr(TERM_EFFECTS[:bright])
         | 
| 45 | 
            -
                end
         | 
| 46 | 
            -
             | 
| 47 | 
            -
                # Turns on italic style for this text (not well supported by terminal
         | 
| 48 | 
            -
                # emulators).
         | 
| 49 | 
            -
                def italic
         | 
| 50 | 
            -
                  wrap_with_sgr(TERM_EFFECTS[:italic])
         | 
| 51 | 
            -
                end
         | 
| 52 | 
            -
             | 
| 53 | 
            -
                # Turns on underline decoration for this text.
         | 
| 54 | 
            -
                def underline
         | 
| 55 | 
            -
                  wrap_with_sgr(TERM_EFFECTS[:underline])
         | 
| 56 | 
            -
                end
         | 
| 57 | 
            -
             | 
| 58 | 
            -
                # Turns on blinking attribute for this text (not well supported by terminal
         | 
| 59 | 
            -
                # emulators).
         | 
| 60 | 
            -
                def blink
         | 
| 61 | 
            -
                  wrap_with_sgr(TERM_EFFECTS[:blink])
         | 
| 62 | 
            -
                end
         | 
| 63 | 
            -
             | 
| 64 | 
            -
                # Inverses current foreground/background colors.
         | 
| 65 | 
            -
                def inverse
         | 
| 66 | 
            -
                  wrap_with_sgr(TERM_EFFECTS[:inverse])
         | 
| 67 | 
            -
                end
         | 
| 68 | 
            -
             | 
| 69 | 
            -
                # Hides this text (set its color to the same as background).
         | 
| 70 | 
            -
                def hide
         | 
| 71 | 
            -
                  wrap_with_sgr(TERM_EFFECTS[:hide])
         | 
| 72 | 
            -
                end
         | 
| 73 | 
            -
             | 
| 74 | 
            -
                def black
         | 
| 75 | 
            -
                  color(:black)
         | 
| 76 | 
            -
                end
         | 
| 77 | 
            -
             | 
| 78 | 
            -
                def red
         | 
| 79 | 
            -
                  color(:red)
         | 
| 80 | 
            -
                end
         | 
| 81 | 
            -
             | 
| 82 | 
            -
                def green
         | 
| 83 | 
            -
                  color(:green)
         | 
| 84 | 
            -
                end
         | 
| 85 | 
            -
             | 
| 86 | 
            -
                def yellow
         | 
| 87 | 
            -
                  color(:yellow)
         | 
| 88 | 
            -
                end
         | 
| 89 | 
            -
             | 
| 90 | 
            -
                def blue
         | 
| 91 | 
            -
                  color(:blue)
         | 
| 92 | 
            -
                end
         | 
| 93 | 
            -
             | 
| 94 | 
            -
                def magenta
         | 
| 95 | 
            -
                  color(:magenta)
         | 
| 96 | 
            -
                end
         | 
| 97 | 
            -
             | 
| 98 | 
            -
                def cyan
         | 
| 99 | 
            -
                  color(:cyan)
         | 
| 100 | 
            -
                end
         | 
| 101 | 
            -
             | 
| 102 | 
            -
                def white
         | 
| 103 | 
            -
                  color(:white)
         | 
| 104 | 
            -
                end
         | 
| 105 | 
            -
             | 
| 106 | 
            -
                # We take care of X11 color method call here.
         | 
| 107 | 
            -
                # Such as #aqua, #ghostwhite.
         | 
| 108 | 
            -
                def method_missing(method_name,*args)
         | 
| 109 | 
            -
                  if Color::X11Named.color_names.include? method_name and args.empty? then
         | 
| 110 | 
            -
                    color(method_name)
         | 
| 111 | 
            -
                  else
         | 
| 112 | 
            -
                    super
         | 
| 113 | 
            -
                  end
         | 
| 114 | 
            -
                end
         | 
| 115 | 
            -
             | 
| 116 | 
            -
                private
         | 
| 117 | 
            -
             | 
| 118 | 
            -
                def wrap_with_sgr(codes) #:nodoc:
         | 
| 119 | 
            -
                  self.class.new(StringUtils.wrap_with_sgr(self, [*codes]))
         | 
| 120 | 
            -
                end
         | 
| 121 | 
            -
             | 
| 122 | 
            -
              end
         | 
| 123 | 
            -
             | 
| 124 | 
            -
            end
         | 
    
        data/lib/rainbow/string_utils.rb
    DELETED
    
    | @@ -1,20 +0,0 @@ | |
| 1 | 
            -
            module Rainbow
         | 
| 2 | 
            -
              class StringUtils
         | 
| 3 | 
            -
             | 
| 4 | 
            -
                def self.wrap_with_sgr(string, codes)
         | 
| 5 | 
            -
                  return string if codes.empty?
         | 
| 6 | 
            -
             | 
| 7 | 
            -
                  seq = "\e[" + codes.join(";") + "m"
         | 
| 8 | 
            -
                  match = string.match(/^(\e\[([\d;]+)m)*/)
         | 
| 9 | 
            -
                  seq_pos = match.end(0)
         | 
| 10 | 
            -
                  string = string[0...seq_pos] + seq + string[seq_pos..-1]
         | 
| 11 | 
            -
             | 
| 12 | 
            -
                  unless string =~ /\e\[0m$/
         | 
| 13 | 
            -
                    string = string + "\e[0m"
         | 
| 14 | 
            -
                  end
         | 
| 15 | 
            -
             | 
| 16 | 
            -
                  string
         | 
| 17 | 
            -
                end
         | 
| 18 | 
            -
             | 
| 19 | 
            -
              end
         | 
| 20 | 
            -
            end
         | 
    
        data/lib/rainbow/version.rb
    DELETED
    
    
    
        data/lib/rainbow/wrapper.rb
    DELETED
    
    | @@ -1,22 +0,0 @@ | |
| 1 | 
            -
            require_relative 'presenter'
         | 
| 2 | 
            -
            require_relative 'null_presenter'
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            module Rainbow
         | 
| 5 | 
            -
             | 
| 6 | 
            -
              class Wrapper
         | 
| 7 | 
            -
                attr_accessor :enabled
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                def initialize(enabled = true)
         | 
| 10 | 
            -
                  @enabled = enabled
         | 
| 11 | 
            -
                end
         | 
| 12 | 
            -
             | 
| 13 | 
            -
                def wrap(string)
         | 
| 14 | 
            -
                  if enabled
         | 
| 15 | 
            -
                    Presenter.new(string.to_s)
         | 
| 16 | 
            -
                  else
         | 
| 17 | 
            -
                    NullPresenter.new(string.to_s)
         | 
| 18 | 
            -
                  end
         | 
| 19 | 
            -
                end
         | 
| 20 | 
            -
              end
         | 
| 21 | 
            -
             | 
| 22 | 
            -
            end
         | 
| @@ -1,152 +0,0 @@ | |
| 1 | 
            -
            module Rainbow
         | 
| 2 | 
            -
             | 
| 3 | 
            -
              module X11ColorNames
         | 
| 4 | 
            -
                NAMES= {
         | 
| 5 | 
            -
                  aqua: [0, 255, 255],
         | 
| 6 | 
            -
                  aquamarine: [127, 255, 212],
         | 
| 7 | 
            -
                  mediumaquamarine: [102, 205, 170],
         | 
| 8 | 
            -
                  azure: [240, 255, 255],
         | 
| 9 | 
            -
                  beige: [245, 245, 220],
         | 
| 10 | 
            -
                  bisque: [255, 228, 196],
         | 
| 11 | 
            -
                  black: [0, 0, 0],
         | 
| 12 | 
            -
                  blanchedalmond: [255, 235, 205],
         | 
| 13 | 
            -
                  blue: [0, 0, 255],
         | 
| 14 | 
            -
                  darkblue: [0, 0, 139],
         | 
| 15 | 
            -
                  lightblue: [173, 216, 230],
         | 
| 16 | 
            -
                  mediumblue: [0, 0, 205],
         | 
| 17 | 
            -
                  aliceblue: [240, 248, 255],
         | 
| 18 | 
            -
                  cadetblue: [95, 158, 160],
         | 
| 19 | 
            -
                  dodgerblue: [30, 144, 255],
         | 
| 20 | 
            -
                  midnightblue: [25, 25, 112],
         | 
| 21 | 
            -
                  navyblue: [0, 0, 128],
         | 
| 22 | 
            -
                  powderblue: [176, 224, 230],
         | 
| 23 | 
            -
                  royalblue: [65, 105, 225],
         | 
| 24 | 
            -
                  skyblue: [135, 206, 235],
         | 
| 25 | 
            -
                  deepskyblue: [0, 191, 255],
         | 
| 26 | 
            -
                  lightskyblue: [135, 206, 250],
         | 
| 27 | 
            -
                  slateblue: [106, 90, 205],
         | 
| 28 | 
            -
                  darkslateblue: [72, 61, 139],
         | 
| 29 | 
            -
                  mediumslateblue: [123, 104, 238],
         | 
| 30 | 
            -
                  steelblue: [70, 130, 180],
         | 
| 31 | 
            -
                  lightsteelblue: [176, 196, 222],
         | 
| 32 | 
            -
                  brown: [165, 42, 42],
         | 
| 33 | 
            -
                  rosybrown: [188, 143, 143],
         | 
| 34 | 
            -
                  saddlebrown: [139, 69, 19],
         | 
| 35 | 
            -
                  sandybrown: [244, 164, 96],
         | 
| 36 | 
            -
                  burlywood: [222, 184, 135],
         | 
| 37 | 
            -
                  chartreuse: [127, 255, 0],
         | 
| 38 | 
            -
                  chocolate: [210, 105, 30],
         | 
| 39 | 
            -
                  coral: [255, 127, 80],
         | 
| 40 | 
            -
                  lightcoral: [240, 128, 128],
         | 
| 41 | 
            -
                  cornflower: [100, 149, 237],
         | 
| 42 | 
            -
                  cornsilk: [255, 248, 220],
         | 
| 43 | 
            -
                  crimson: [220, 20, 60],
         | 
| 44 | 
            -
                  cyan: [0, 255, 255],
         | 
| 45 | 
            -
                  darkcyan: [0, 139, 139],
         | 
| 46 | 
            -
                  lightcyan: [224, 255, 255],
         | 
| 47 | 
            -
                  firebrick: [178, 34, 34],
         | 
| 48 | 
            -
                  fuchsia: [255, 0, 255],
         | 
| 49 | 
            -
                  gainsboro: [220, 220, 220],
         | 
| 50 | 
            -
                  gold: [255, 215, 0],
         | 
| 51 | 
            -
                  goldenrod: [218, 165, 32],
         | 
| 52 | 
            -
                  darkgoldenrod: [184, 134, 11],
         | 
| 53 | 
            -
                  lightgoldenrod: [250, 250, 210],
         | 
| 54 | 
            -
                  palegoldenrod: [238, 232, 170],
         | 
| 55 | 
            -
                  gray: [190, 190, 190],
         | 
| 56 | 
            -
                  darkgray: [169, 169, 169],
         | 
| 57 | 
            -
                  dimgray: [105, 105, 105],
         | 
| 58 | 
            -
                  lightgray: [211, 211, 211],
         | 
| 59 | 
            -
                  slategray: [112, 128, 144],
         | 
| 60 | 
            -
                  lightslategray: [119, 136, 153],
         | 
| 61 | 
            -
                  webgray: [128, 128, 128],
         | 
| 62 | 
            -
                  green: [0, 255, 0],
         | 
| 63 | 
            -
                  darkgreen: [0, 100, 0],
         | 
| 64 | 
            -
                  lightgreen: [144, 238, 144],
         | 
| 65 | 
            -
                  palegreen: [152, 251, 152],
         | 
| 66 | 
            -
                  darkolivegreen: [85, 107, 47],
         | 
| 67 | 
            -
                  yellowgreen: [154, 205, 50],
         | 
| 68 | 
            -
                  forestgreen: [34, 139, 34],
         | 
| 69 | 
            -
                  lawngreen: [124, 252, 0],
         | 
| 70 | 
            -
                  limegreen: [50, 205, 50],
         | 
| 71 | 
            -
                  seagreen: [46, 139, 87],
         | 
| 72 | 
            -
                  darkseagreen: [143, 188, 143],
         | 
| 73 | 
            -
                  lightseagreen: [32, 178, 170],
         | 
| 74 | 
            -
                  mediumseagreen: [60, 179, 113],
         | 
| 75 | 
            -
                  springgreen: [0, 255, 127],
         | 
| 76 | 
            -
                  mediumspringgreen: [0, 250, 154],
         | 
| 77 | 
            -
                  webgreen: [0, 128, 0],
         | 
| 78 | 
            -
                  honeydew: [240, 255, 240],
         | 
| 79 | 
            -
                  indianred: [205, 92, 92],
         | 
| 80 | 
            -
                  indigo: [75, 0, 130],
         | 
| 81 | 
            -
                  ivory: [255, 255, 240],
         | 
| 82 | 
            -
                  khaki: [240, 230, 140],
         | 
| 83 | 
            -
                  darkkhaki: [189, 183, 107],
         | 
| 84 | 
            -
                  lavender: [230, 230, 250],
         | 
| 85 | 
            -
                  lavenderblush: [255, 240, 245],
         | 
| 86 | 
            -
                  lemonchiffon: [255, 250, 205],
         | 
| 87 | 
            -
                  lime: [0, 255, 0],
         | 
| 88 | 
            -
                  linen: [250, 240, 230],
         | 
| 89 | 
            -
                  magenta: [255, 0, 255],
         | 
| 90 | 
            -
                  darkmagenta: [139, 0, 139],
         | 
| 91 | 
            -
                  maroon: [176, 48, 96],
         | 
| 92 | 
            -
                  webmaroon: [127, 0, 0],
         | 
| 93 | 
            -
                  mintcream: [245, 255, 250],
         | 
| 94 | 
            -
                  mistyrose: [255, 228, 225],
         | 
| 95 | 
            -
                  moccasin: [255, 228, 181],
         | 
| 96 | 
            -
                  oldlace: [253, 245, 230],
         | 
| 97 | 
            -
                  olive: [128, 128, 0],
         | 
| 98 | 
            -
                  olivedrab: [107, 142, 35],
         | 
| 99 | 
            -
                  orange: [255, 165, 0],
         | 
| 100 | 
            -
                  darkorange: [255, 140, 0],
         | 
| 101 | 
            -
                  orchid: [218, 112, 214],
         | 
| 102 | 
            -
                  darkorchid: [153, 50, 204],
         | 
| 103 | 
            -
                  mediumorchid: [186, 85, 211],
         | 
| 104 | 
            -
                  papayawhip: [255, 239, 213],
         | 
| 105 | 
            -
                  peachpuff: [255, 218, 185],
         | 
| 106 | 
            -
                  peru: [205, 133, 63],
         | 
| 107 | 
            -
                  pink: [255, 192, 203],
         | 
| 108 | 
            -
                  deeppink: [255, 20, 147],
         | 
| 109 | 
            -
                  lightpink: [255, 182, 193],
         | 
| 110 | 
            -
                  hotpink: [255, 105, 180],
         | 
| 111 | 
            -
                  plum: [221, 160, 221],
         | 
| 112 | 
            -
                  purple: [160, 32, 240],
         | 
| 113 | 
            -
                  mediumpurple: [147, 112, 219],
         | 
| 114 | 
            -
                  rebeccapurple: [102, 51, 153],
         | 
| 115 | 
            -
                  webpurple: [127, 0, 127],
         | 
| 116 | 
            -
                  red: [255, 0, 0],
         | 
| 117 | 
            -
                  darkred: [139, 0, 0],
         | 
| 118 | 
            -
                  orangered: [255, 69, 0],
         | 
| 119 | 
            -
                  mediumvioletred: [199, 21, 133],
         | 
| 120 | 
            -
                  palevioletred: [219, 112, 147],
         | 
| 121 | 
            -
                  salmon: [250, 128, 114],
         | 
| 122 | 
            -
                  darksalmon: [233, 150, 122],
         | 
| 123 | 
            -
                  lightsalmon: [255, 160, 122],
         | 
| 124 | 
            -
                  seashell: [255, 245, 238],
         | 
| 125 | 
            -
                  sienna: [160, 82, 45],
         | 
| 126 | 
            -
                  silver: [192, 192, 192],
         | 
| 127 | 
            -
                  darkslategray: [47, 79, 79],
         | 
| 128 | 
            -
                  snow: [255, 250, 250],
         | 
| 129 | 
            -
                  tan: [210, 180, 140],
         | 
| 130 | 
            -
                  teal: [0, 128, 128],
         | 
| 131 | 
            -
                  thistle: [216, 191, 216],
         | 
| 132 | 
            -
                  tomato: [255, 99, 71],
         | 
| 133 | 
            -
                  turquoise: [64, 224, 208],
         | 
| 134 | 
            -
                  darkturquoise: [0, 206, 209],
         | 
| 135 | 
            -
                  mediumturquoise: [72, 209, 204],
         | 
| 136 | 
            -
                  paleturquoise: [175, 238, 238],
         | 
| 137 | 
            -
                  violet: [238, 130, 238],
         | 
| 138 | 
            -
                  darkviolet: [148, 0, 211],
         | 
| 139 | 
            -
                  blueviolet: [138, 43, 226],
         | 
| 140 | 
            -
                  wheat: [245, 222, 179],
         | 
| 141 | 
            -
                  white: [255, 255, 255],
         | 
| 142 | 
            -
                  antiquewhite: [250, 235, 215],
         | 
| 143 | 
            -
                  floralwhite: [255, 250, 240],
         | 
| 144 | 
            -
                  ghostwhite: [248, 248, 255],
         | 
| 145 | 
            -
                  navajowhite: [255, 222, 173],
         | 
| 146 | 
            -
                  whitesmoke: [245, 245, 245],
         | 
| 147 | 
            -
                  yellow: [255, 255, 0],
         | 
| 148 | 
            -
                  lightyellow: [255, 255, 224],
         | 
| 149 | 
            -
                  greenyellow: [173, 255, 47]
         | 
| 150 | 
            -
                }
         | 
| 151 | 
            -
              end
         | 
| 152 | 
            -
            end
         | 
    
        data/lib/rainbow.rb
    DELETED
    
    | @@ -1,25 +0,0 @@ | |
| 1 | 
            -
            require_relative 'rainbow/global'
         | 
| 2 | 
            -
            require_relative 'rainbow/legacy'
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            module Rainbow
         | 
| 5 | 
            -
             | 
| 6 | 
            -
              def self.new
         | 
| 7 | 
            -
                Wrapper.new(global.enabled)
         | 
| 8 | 
            -
              end
         | 
| 9 | 
            -
             | 
| 10 | 
            -
              self.enabled = false unless STDOUT.tty? && STDERR.tty?
         | 
| 11 | 
            -
              self.enabled = false if ENV['TERM'] == 'dumb'
         | 
| 12 | 
            -
              self.enabled = true if ENV['CLICOLOR_FORCE'] == '1'
         | 
| 13 | 
            -
             | 
| 14 | 
            -
              # On Windows systems, try to load the local ANSI support library if Ruby version < 2
         | 
| 15 | 
            -
              # Ruby 2.x on Windows includes ANSI support. 
         | 
| 16 | 
            -
              require 'rbconfig'
         | 
| 17 | 
            -
              if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/  && RUBY_VERSION.to_i < 2
         | 
| 18 | 
            -
                begin
         | 
| 19 | 
            -
                  require 'Win32/Console/ANSI'
         | 
| 20 | 
            -
                rescue LoadError
         | 
| 21 | 
            -
                  self.enabled = false
         | 
| 22 | 
            -
                end
         | 
| 23 | 
            -
              end
         | 
| 24 | 
            -
             | 
| 25 | 
            -
            end
         | 
    
        data/rainbow.gemspec
    DELETED
    
    | @@ -1,23 +0,0 @@ | |
| 1 | 
            -
            # coding: utf-8
         | 
| 2 | 
            -
            lib = File.expand_path('../lib', __FILE__)
         | 
| 3 | 
            -
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         | 
| 4 | 
            -
            require 'rainbow/version'
         | 
| 5 | 
            -
             | 
| 6 | 
            -
            Gem::Specification.new do |spec|
         | 
| 7 | 
            -
              spec.name                  = "rainbow"
         | 
| 8 | 
            -
              spec.version               = Rainbow::VERSION
         | 
| 9 | 
            -
              spec.authors               = ["Marcin Kulik"]
         | 
| 10 | 
            -
              spec.email                 = ["m@ku1ik.com"]
         | 
| 11 | 
            -
              spec.description           = %q(Colorize printed text on ANSI terminals)
         | 
| 12 | 
            -
              spec.summary               = %q(Colorize printed text on ANSI terminals)
         | 
| 13 | 
            -
              spec.homepage              = "https://github.com/sickill/rainbow"
         | 
| 14 | 
            -
              spec.license               = "MIT"
         | 
| 15 | 
            -
              spec.required_ruby_version = '>= 1.9.2'
         | 
| 16 | 
            -
             | 
| 17 | 
            -
              spec.files         = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
         | 
| 18 | 
            -
              spec.executables   = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
         | 
| 19 | 
            -
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         | 
| 20 | 
            -
              spec.require_paths = ["lib"]
         | 
| 21 | 
            -
             | 
| 22 | 
            -
              spec.add_development_dependency "bundler", "~> 1.3"
         | 
| 23 | 
            -
            end
         | 
| @@ -1,35 +0,0 @@ | |
| 1 | 
            -
            require 'spec_helper'
         | 
| 2 | 
            -
            require 'rainbow'
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            describe 'Custom Rainbow instance' do
         | 
| 5 | 
            -
             | 
| 6 | 
            -
              it 'inherits enabled state from the global instance' do
         | 
| 7 | 
            -
                Rainbow.enabled = :yep
         | 
| 8 | 
            -
                expect(Rainbow.new.enabled).to eq(:yep)
         | 
| 9 | 
            -
              end
         | 
| 10 | 
            -
             | 
| 11 | 
            -
              it 'tracks its own state separately from the global instance' do
         | 
| 12 | 
            -
                Rainbow.enabled = :yep
         | 
| 13 | 
            -
                rainbow = Rainbow.new
         | 
| 14 | 
            -
                expect(Rainbow.new.enabled).to eq(:yep)
         | 
| 15 | 
            -
             | 
| 16 | 
            -
                rainbow.enabled = :nope
         | 
| 17 | 
            -
                expect(Rainbow.enabled).to eq(:yep)
         | 
| 18 | 
            -
                expect(rainbow.enabled).to eq(:nope)
         | 
| 19 | 
            -
              end
         | 
| 20 | 
            -
             | 
| 21 | 
            -
              it 'wraps string with escape codes when enabled' do
         | 
| 22 | 
            -
                rainbow = Rainbow.new
         | 
| 23 | 
            -
                rainbow.enabled = true
         | 
| 24 | 
            -
             | 
| 25 | 
            -
                expect(rainbow.wrap('hello').green).to eq("\e[32mhello\e[0m")
         | 
| 26 | 
            -
              end
         | 
| 27 | 
            -
             | 
| 28 | 
            -
              it "doesn't wrap string with any escape code when disabled" do
         | 
| 29 | 
            -
                rainbow = Rainbow.new
         | 
| 30 | 
            -
                rainbow.enabled = false
         | 
| 31 | 
            -
             | 
| 32 | 
            -
                expect(rainbow.wrap('hello').green).to eq('hello')
         | 
| 33 | 
            -
              end
         | 
| 34 | 
            -
             | 
| 35 | 
            -
            end
         |