rainbow-3.0.0/0000755000004100000410000000000013312112606013176 5ustar www-datawww-datarainbow-3.0.0/.travis.yml0000644000004100000410000000064413312112606015313 0ustar www-datawww-datalanguage: ruby cache: bundler: true before_install: - gem install bundler bundler_args: --without guard development matrix: include: - rvm: 2.1.10 - rvm: 2.2.7 - rvm: 2.3.4 - rvm: 2.4.1 - rvm: jruby-9.1.14.0 jdk: oraclejdk8 - rvm: 2.2.7 install: true # This skips 'bundle install' script: gem build rainbow && gem install *.gem env: global: - JRUBY_OPTS=--debug rainbow-3.0.0/spec/0000755000004100000410000000000013312112606014130 5ustar www-datawww-datarainbow-3.0.0/spec/unit/0000755000004100000410000000000013312112606015107 5ustar www-datawww-datarainbow-3.0.0/spec/unit/string_utils_spec.rb0000644000004100000410000000456613312112606021207 0ustar www-datawww-datarequire 'spec_helper' require 'rainbow/string_utils' module Rainbow RSpec.describe StringUtils do describe '.wrap_with_sgr' do subject { described_class.wrap_with_sgr(string, codes) } let(:string) { 'hello' } let(:codes) { [1] } it "doesn't mutate original string" do string.freeze expect(subject).to eq("\e[1mhello\e[0m") expect(string).to eq('hello') end context "when subclass of String class given" do class Stringgg < ::String; end let(:string) { Stringgg.new('hello') } it { should eq("\e[1mhello\e[0m") } end context "when no codes given" do let(:codes) { [] } it "doesn't wrap the given string with any sgr sequence" do expect(subject).to eq("hello") end end context "when single code given" do let(:codes) { [1] } it "wraps the given string with sgr sequence for given codes" do expect(subject).to eq("\e[1mhello\e[0m") end end context "when multiple codes given" do let(:codes) { [1, 2] } it "wraps the given string with sgr sequence for given codes" do expect(subject).to eq("\e[1;2mhello\e[0m") end end context "when wrapping an already wrapped string" do let(:string) { "\e[1;2mhello\e[0m" } let(:codes) { [3, 4] } it "wraps the given string with sgr sequence for given codes" do expect(subject).to eq("\e[1;2m\e[3;4mhello\e[0m") end end end describe '.uncolor' do subject { described_class.uncolor(string) } context "when string with ansi color escape is passed" do let(:string) do rainbow = Rainbow.new rainbow.enabled = true rainbow.wrap('hello'). foreground(:red). bright. bold. italic. background('#ff8040'). underline. color(:blue). blink. inverse. hide end it "removes ansi color codes" do expect(subject).to eq 'hello' end end context "when string with scroll down ansi escape is passed" do let(:string) { "\e[1Thello" } it "does not remove ansi scroll down escape" do expect(subject).to eq "\e[1Thello" end end end end end rainbow-3.0.0/spec/unit/color_spec.rb0000644000004100000410000001526413312112606017574 0ustar www-datawww-datarequire 'spec_helper' require 'rainbow/color' module Rainbow RSpec.describe Color do describe '.build' do subject { described_class.build(ground, values) } let(:ground) { :foreground } context "when single fixnum given" do let(:values) { [1] } it { should be_instance_of(Color::Indexed) } specify { expect(subject.ground).to eq(ground) } specify { expect(subject.num).to eq(1) } end context "when single ansi symbol given" do let(:values) { [:red] } it { should be_instance_of(Color::Named) } specify { expect(subject.ground).to eq(ground) } specify { expect(subject.num).to eq(1) } end context "when single x11 symbol given" do let(:values) { [:midnightblue] } it { should be_instance_of(Color::X11Named) } specify { expect(subject.ground).to eq(ground) } specify { expect(subject.r).to eq(25) } specify { expect(subject.g).to eq(25) } specify { expect(subject.b).to eq(112) } end context "when single string given" do let(:values) { ['#deadcc'] } it { should be_instance_of(Color::RGB) } specify { expect(subject.ground).to eq(ground) } specify { expect(subject.r).to eq(222) } specify { expect(subject.g).to eq(173) } specify { expect(subject.b).to eq(204) } end context "when 2 elements" do let(:values) { [1, 2] } it 'raises ArgumentError' do expect { subject }.to raise_error(ArgumentError) end end context "when 3 elements given" do let(:values) { [1, 2, 3] } it { should be_instance_of(Color::RGB) } specify { expect(subject.ground).to eq(ground) } specify { expect(subject.r).to eq(1) } specify { expect(subject.g).to eq(2) } specify { expect(subject.b).to eq(3) } end context "when 4 elements" do let(:values) { [1, 2, 3, 4] } it 'raises ArgumentError' do expect { subject }.to raise_error(ArgumentError) end end end end RSpec.describe Color::Indexed do let(:color) { described_class.new(ground, 5) } describe '#codes' do subject { color.codes } context "when ground is :foreground" do let(:ground) { :foreground } it { should eq([35]) } end context "when ground is :background" do let(:ground) { :background } it { should eq([45]) } end end end RSpec.describe Color::Named do let(:color) { described_class.new(ground, name) } describe '#codes' do subject { color.codes } context "when ground is :foreground" do let(:ground) { :foreground } context "and name is :black" do let(:name) { :black } it { should eq([30]) } end context "and name is :red" do let(:name) { :red } it { should eq([31]) } end context "and name is :green" do let(:name) { :green } it { should eq([32]) } end context "and name is :yellow" do let(:name) { :yellow } it { should eq([33]) } end context "and name is :blue" do let(:name) { :blue } it { should eq([34]) } end context "and name is :magenta" do let(:name) { :magenta } it { should eq([35]) } end context "and name is :cyan" do let(:name) { :cyan } it { should eq([36]) } end context "and name is :white" do let(:name) { :white } it { should eq([37]) } end context "and name is invalid" do let(:name) { :foo } it 'raises ArgumentError' do expect { subject }.to raise_error(ArgumentError) end end end context "when ground is :background" do let(:ground) { :background } context "and name is :black" do let(:name) { :black } it { should eq([40]) } end context "and name is :red" do let(:name) { :red } it { should eq([41]) } end context "and name is :green" do let(:name) { :green } it { should eq([42]) } end context "and name is :yellow" do let(:name) { :yellow } it { should eq([43]) } end context "and name is :blue" do let(:name) { :blue } it { should eq([44]) } end context "and name is :magenta" do let(:name) { :magenta } it { should eq([45]) } end context "and name is :cyan" do let(:name) { :cyan } it { should eq([46]) } end context "and name is :white" do let(:name) { :white } it { should eq([47]) } end context "and name is invalid" do let(:name) { :foo } it 'raises ArgumentError' do expect { subject }.to raise_error(ArgumentError) end end end end end RSpec.describe Color::RGB do let(:color) { described_class.new(ground, r, g, b) } describe '#codes' do subject { color.codes } let(:ground) { :foreground } let(:r) { 0 } let(:g) { 128 } let(:b) { 255 } context "when ground is :foreground" do let(:ground) { :foreground } it { should eq([38, 5, 39]) } end context "when ground is :background" do let(:ground) { :background } it { should eq([48, 5, 39]) } end context "when a component is lower than 0" do let(:r) { -1 } it 'raises ArgumentError' do expect { subject }.to raise_error(ArgumentError) end end context "when a component is greater than 255" do let(:b) { 256 } it 'raises ArgumentError' do expect { subject }.to raise_error(ArgumentError) end end end end RSpec.describe Color::X11Named do let(:color) { described_class.new(ground, name) } describe '#codes' do subject { color.codes } context "when ground is :foreground" do let(:name) { :midnightblue } let(:ground) { :foreground } it { should eq([38, 5, 18]) } end context "when ground is :background" do let(:name) { :midnightblue } let(:ground) { :background } it { should eq([48, 5, 18]) } end context "when name is invalid" do let(:name) { :foo } let(:ground) { :background } it 'raises ArgumentError' do expect { subject }.to raise_error(ArgumentError) end end end end end rainbow-3.0.0/spec/unit/presenter_spec.rb0000644000004100000410000001111213312112606020451 0ustar www-datawww-datarequire 'spec_helper' require 'rainbow/presenter' module Rainbow RSpec.describe Presenter do let(:presenter) { described_class.new('hello') } shared_examples_for "rainbow string method" do it "wraps the text with a sgr sequence" do expect(subject).to eq('[hello]') end it "returns an instance of Rainbow::Presenter" do expect(subject).to be_kind_of(Rainbow::Presenter) end end shared_examples_for "text color method" do let(:color) { double('color', codes: [1, 2]) } before do allow(Color).to receive(:build) .with(:foreground, [:arg1, 'arg2']) { color } end it_behaves_like "rainbow string method" it 'wraps with color codes' do subject expect(StringUtils).to have_received(:wrap_with_sgr) .with('hello', [1, 2]) end end shared_examples_for "text background method" do let(:color) { double('color', codes: [1, 2]) } before do allow(Color).to receive(:build) .with(:background, [:arg1, 'arg2']) { color } end it_behaves_like "rainbow string method" it 'wraps with color codes' do subject expect(StringUtils).to have_received(:wrap_with_sgr) .with('hello', [1, 2]) end end before do allow(StringUtils).to receive(:wrap_with_sgr) { '[hello]' } end describe '#color' do subject { presenter.color(:arg1, 'arg2') } it_behaves_like "text color method" end describe '#foreground' do subject { presenter.foreground(:arg1, 'arg2') } it_behaves_like "text color method" end describe '#fg' do subject { presenter.fg(:arg1, 'arg2') } it_behaves_like "text color method" end describe '#background' do subject { presenter.background(:arg1, 'arg2') } it_behaves_like "text background method" end describe '#bg' do subject { presenter.bg(:arg1, 'arg2') } it_behaves_like "text background method" end describe '#reset' do subject { presenter.reset } it_behaves_like "rainbow string method" it 'wraps with 0 code' do subject expect(StringUtils).to have_received(:wrap_with_sgr).with('hello', [0]) end end describe '#bright' do subject { presenter.bright } it_behaves_like "rainbow string method" it 'wraps with 1 code' do subject expect(StringUtils).to have_received(:wrap_with_sgr).with('hello', [1]) end end describe '#bold' do subject { presenter.bold } it_behaves_like "rainbow string method" it 'wraps with 1 code' do subject expect(StringUtils).to have_received(:wrap_with_sgr).with('hello', [1]) end end describe '#faint' do subject { presenter.faint } it_behaves_like "rainbow string method" it 'wraps with 2 code' do subject expect(StringUtils).to have_received(:wrap_with_sgr).with('hello', [2]) end end describe '#dark' do subject { presenter.dark } it_behaves_like "rainbow string method" it 'wraps with 2 code' do subject expect(StringUtils).to have_received(:wrap_with_sgr).with('hello', [2]) end end describe '#italic' do subject { presenter.italic } it_behaves_like "rainbow string method" it 'wraps with 3 code' do subject expect(StringUtils).to have_received(:wrap_with_sgr) .with('hello', [3]) end end describe '#underline' do subject { presenter.underline } it_behaves_like "rainbow string method" it 'wraps with 4 code' do subject expect(StringUtils).to have_received(:wrap_with_sgr).with('hello', [4]) end end describe '#blink' do subject { presenter.blink } it_behaves_like "rainbow string method" it 'wraps with 5 code' do subject expect(StringUtils).to have_received(:wrap_with_sgr).with('hello', [5]) end end describe '#inverse' do subject { presenter.inverse } it_behaves_like "rainbow string method" it 'wraps with 7 code' do subject expect(StringUtils).to have_received(:wrap_with_sgr).with('hello', [7]) end end describe '#hide' do subject { presenter.hide } it_behaves_like "rainbow string method" it 'wraps with 8 code' do subject expect(StringUtils).to have_received(:wrap_with_sgr).with('hello', [8]) end end it_behaves_like "presenter with shortcut color methods" end end rainbow-3.0.0/spec/unit/null_presenter_spec.rb0000644000004100000410000000457313312112606021520 0ustar www-datawww-datarequire 'spec_helper' require 'rainbow/null_presenter' module Rainbow RSpec.describe NullPresenter do let(:presenter) { described_class.new('hello') } shared_examples_for "rainbow null string method" do it "doesn't wrap the text with any sgr sequence" do expect(subject).to eq('hello') end it "returns an instance of Rainbow::NullPresenter" do expect(subject).to be_kind_of(Rainbow::NullPresenter) end end describe '#color' do subject { presenter.color(:arg1, 'arg2') } it_behaves_like "rainbow null string method" end describe '#foreground' do subject { presenter.foreground(:arg1, 'arg2') } it_behaves_like "rainbow null string method" end describe '#fg' do subject { presenter.fg(:arg1, 'arg2') } it_behaves_like "rainbow null string method" end describe '#background' do subject { presenter.background(:arg1, 'arg2') } it_behaves_like "rainbow null string method" end describe '#bg' do subject { presenter.bg(:arg1, 'arg2') } it_behaves_like "rainbow null string method" end describe '#reset' do subject { presenter.reset } it_behaves_like "rainbow null string method" end describe '#bright' do subject { presenter.bright } it_behaves_like "rainbow null string method" end describe '#bold' do subject { presenter.bold } it_behaves_like "rainbow null string method" end describe '#faint' do subject { presenter.faint } it_behaves_like "rainbow null string method" end describe '#dark' do subject { presenter.dark } it_behaves_like "rainbow null string method" end describe '#italic' do subject { presenter.italic } it_behaves_like "rainbow null string method" end describe '#underline' do subject { presenter.underline } it_behaves_like "rainbow null string method" end describe '#blink' do subject { presenter.blink } it_behaves_like "rainbow null string method" end describe '#inverse' do subject { presenter.inverse } it_behaves_like "rainbow null string method" end describe '#hide' do subject { presenter.hide } it_behaves_like "rainbow null string method" end it_behaves_like "presenter with shortcut color methods" end end rainbow-3.0.0/spec/unit/wrapper_spec.rb0000644000004100000410000000131713312112606020130 0ustar www-datawww-datarequire 'spec_helper' require 'rainbow/wrapper' module Rainbow RSpec.describe Wrapper do let(:wrapper) { described_class.new(enabled) } it "is enabled by default" do expect(described_class.new.enabled).to be(true) end describe '#wrap' do subject { wrapper.wrap(object) } let(:object) { Object.new } context "when wrapping is enabled" do let(:enabled) { true } it { should eq(object.to_s) } it { should be_kind_of(Rainbow::Presenter) } end context "when wrapping is disabled" do let(:enabled) { false } it { should eq(object.to_s) } it { should be_kind_of(Rainbow::NullPresenter) } end end end end rainbow-3.0.0/spec/spec_helper.rb0000644000004100000410000000040413312112606016744 0ustar www-datawww-dataif ENV["CI"] && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby") require 'coveralls' Coveralls.wear! end Dir[File.expand_path('../support/**/*.rb', __FILE__)].each { |file| require file } RSpec.configure do |config| config.disable_monkey_patching! endrainbow-3.0.0/spec/support/0000755000004100000410000000000013312112606015644 5ustar www-datawww-datarainbow-3.0.0/spec/support/presenter_shared_examples.rb0000644000004100000410000000043013312112606023421 0ustar www-datawww-dataRSpec.shared_examples_for "presenter with shortcut color methods" do %i[black red green yellow blue magenta cyan white aqua].each do |name| describe "##{name}" do subject { presenter.public_send(name) } it { should eq(presenter.color(name)) } end end end rainbow-3.0.0/spec/integration/0000755000004100000410000000000013312112606016453 5ustar www-datawww-datarainbow-3.0.0/spec/integration/string_spec.rb0000644000004100000410000000413013312112606021316 0ustar www-datawww-datarequire 'spec_helper' require 'rainbow/ext/string' RSpec.describe 'String mixin' do before do Rainbow.enabled = true end it 'proxies foreground to Rainbow().foreground' do expect('hello'.foreground(:red)).to eq(Rainbow('hello').foreground(:red)) end it 'proxies color to Rainbow().color' do expect('hello'.color(:red)).to eq(Rainbow('hello').color(:red)) end it 'proxies x11 color to Rainbow().color' do expect('hello'.color(:midnightblue)).to eq(Rainbow('hello').color(:midnightblue)) end it 'proxies colour to Rainbow().colour' do expect('hello'.colour(:red)).to eq(Rainbow('hello').colour(:red)) end it 'proxies background to Rainbow().background' do expect('hello'.background(:red)).to eq(Rainbow('hello').background(:red)) end it 'proxies bright to Rainbow().bright' do expect('hello'.bright).to eq(Rainbow('hello').bright) end it 'proxies faint to Rainbow().faint' do expect('hello'.faint).to eq(Rainbow('hello').faint) end it 'proxies italic to Rainbow().italic' do expect('hello'.italic).to eq(Rainbow('hello').italic) end it 'proxies underline to Rainbow().underline' do expect('hello'.underline).to eq(Rainbow('hello').underline) end it 'proxies blink to Rainbow().blink' do expect('hello'.blink).to eq(Rainbow('hello').blink) end it 'proxies inverse to Rainbow().inverse' do expect('hello'.inverse).to eq(Rainbow('hello').inverse) end it 'proxies hide to Rainbow().hide' do expect('hello'.hide).to eq(Rainbow('hello').hide) end it 'proxies reset to Rainbow().reset' do expect('hello'.reset).to eq(Rainbow('hello').reset) end context "when Rainbow is disabled" do before do Rainbow.enabled = false end it "allows chaining but doesn't wrap with escape codes" do result = 'hello' .foreground(:red) .bright .italic .background('#ff8040') .underline .color(:blue) .blink .inverse .hide expect(result).to eq('hello') end end end rainbow-3.0.0/spec/integration/refinement_spec.rb0000644000004100000410000000126113312112606022146 0ustar www-datawww-datarequire 'spec_helper' require 'rainbow' RSpec.describe 'Rainbow refinement' do before do require 'rainbow/refinement' class ScopeNotIncluded def self.red_hello 'hello'.red end end class ScopeIncluded using Rainbow def self.red_hello 'hello'.red end end end it 'is not active by default' do expect do ScopeNotIncluded.red_hello end.to raise_error(NoMethodError) end it 'is available when used' do expect(ScopeIncluded.red_hello).to eq(Rainbow('hello').red) end it 'respects disabled state' do Rainbow.enabled = false expect(ScopeIncluded.red_hello).to eq('hello') end end rainbow-3.0.0/spec/integration/instance_spec.rb0000644000004100000410000000154413312112606021622 0ustar www-datawww-datarequire 'spec_helper' require 'rainbow' RSpec.describe 'Custom Rainbow instance' do it 'inherits enabled state from the global instance' do Rainbow.enabled = :yep expect(Rainbow.new.enabled).to eq(:yep) end it 'tracks its own state separately from the global instance' do Rainbow.enabled = :yep rainbow = Rainbow.new expect(Rainbow.new.enabled).to eq(:yep) rainbow.enabled = :nope expect(Rainbow.enabled).to eq(:yep) expect(rainbow.enabled).to eq(:nope) end it 'wraps string with escape codes when enabled' do rainbow = Rainbow.new rainbow.enabled = true expect(rainbow.wrap('hello').green).to eq("\e[32mhello\e[0m") end it "doesn't wrap string with any escape code when disabled" do rainbow = Rainbow.new rainbow.enabled = false expect(rainbow.wrap('hello').green).to eq('hello') end end rainbow-3.0.0/spec/integration/rainbow_spec.rb0000644000004100000410000001017713312112606021461 0ustar www-datawww-datarequire 'spec_helper' require 'rainbow' RSpec.describe 'Rainbow() wrapper' do before do Rainbow.enabled = true end it 'allows foreground coloring by color number' do result = Rainbow('hello').foreground(5) expect(result).to eq("\e[35mhello\e[0m") end it 'allows foreground coloring by color name' do result = Rainbow('hello').foreground(:red) expect(result).to eq("\e[31mhello\e[0m") end it 'allows foreground coloring directly by ANSI method name' do result = Rainbow('hello').red expect(result).to eq("\e[31mhello\e[0m") end it 'allows foreground coloring directly by X11 method name' do result = Rainbow('hello').midnightblue expect(result).to eq("\e[38;5;18mhello\e[0m") end it 'allows foreground coloring by ANSI color name (color alias)' do result = Rainbow('hello').color(:red) expect(result).to eq("\e[31mhello\e[0m") end it 'allows foreground coloring by color name (colour alias)' do result = Rainbow('hello').colour(:red) expect(result).to eq("\e[31mhello\e[0m") end it 'allows foreground coloring by X11 color name' do result = Rainbow('hello').foreground(:midnightblue) expect(result).to eq("\e[38;5;18mhello\e[0m") end it 'allows foreground coloring by color rgb' do result = Rainbow('hello').foreground(255, 128, 64) expect(result).to eq("\e[38;5;215mhello\e[0m") end it 'allows foreground coloring by color rgb (hex string)' do result = Rainbow('hello').foreground('ff8040') expect(result).to eq("\e[38;5;215mhello\e[0m") end it 'allows background coloring by color number' do result = Rainbow('hello').background(3) expect(result).to eq("\e[43mhello\e[0m") end it 'allows background coloring by ANSI color name' do result = Rainbow('hello').background(:green) expect(result).to eq("\e[42mhello\e[0m") end it 'allows background coloring by X11 color name' do result = Rainbow('hello').background(:midnightblue) expect(result).to eq("\e[48;5;18mhello\e[0m") end it 'allows background coloring by color rgb' do result = Rainbow('hello').background(255, 128, 64) expect(result).to eq("\e[48;5;215mhello\e[0m") end it 'allows making text bright' do result = Rainbow('hello').bright expect(result).to eq("\e[1mhello\e[0m") end it 'allows making text faint' do result = Rainbow('hello').faint expect(result).to eq("\e[2mhello\e[0m") end it 'allows making text italic' do result = Rainbow('hello').italic expect(result).to eq("\e[3mhello\e[0m") end it 'allows making text underlined' do result = Rainbow('hello').underline expect(result).to eq("\e[4mhello\e[0m") end it 'allows making text blinking' do result = Rainbow('hello').blink expect(result).to eq("\e[5mhello\e[0m") end it 'allows making text inversed' do result = Rainbow('hello').inverse expect(result).to eq("\e[7mhello\e[0m") end it 'allows making text hidden' do result = Rainbow('hello').hide expect(result).to eq("\e[8mhello\e[0m") end it 'allows resetting all the attributes' do result = Rainbow('hello').reset expect(result).to eq("\e[0mhello\e[0m") end it 'allows chaining' do result = Rainbow('hello') .foreground(:red) .bright .bold .faint .dark .italic .background('#ff8040') .underline .color(:blue) .blink .inverse .hide expect(result).to eq( "\e[31m\e[1m\e[1m\e[2m\e[2m\e[3m\e[48;5;215m\e[4m\e[34m\e[5m\e[7m\e[8mhello\e[0m" ) end context "when Rainbow is disabled" do before do Rainbow.enabled = false end it "allows chaining but doesn't wrap with escape codes" do result = Rainbow('hello') .foreground(:red) .bright .bold .faint .dark .italic .background('#ff8040') .underline .color(:blue) .blink .inverse .hide expect(result).to eq('hello') end end end rainbow-3.0.0/spec/integration/uncolor_spec.rb0000644000004100000410000000046513312112606021500 0ustar www-datawww-datarequire 'spec_helper' require 'rainbow' RSpec.describe 'uncolor method' do it 'strips ansi color escape code' do expect(Rainbow.uncolor("\e[35mhello\e[0mm")).to eq 'hellom' end it 'does not strip scroll down escape code' do expect(Rainbow.uncolor("\e[1Thello")).to eq "\e[1Thello" end end rainbow-3.0.0/.rubocop.yml0000644000004100000410000000044613312112606015454 0ustar www-datawww-datainherit_from: .rubocop_todo.yml AllCops: DisplayCopNames: true DisplayStyleGuide: true TargetRubyVersion: "2.1" Exclude: - "spec/**/*" - "vendor/**/*" Documentation: Enabled: false HashSyntax: Enabled: false MethodName: Enabled: false StringLiterals: Enabled: false rainbow-3.0.0/.gitignore0000644000004100000410000000023213312112606015163 0ustar www-datawww-data*.gem *.rbc .bundle .config .yardoc Gemfile.lock InstalledFiles _yardoc coverage doc/ lib/bundler/man pkg rdoc spec/reports test/tmp test/version_tmp tmp rainbow-3.0.0/LICENSE0000644000004100000410000000203313312112606014201 0ustar www-datawww-dataCopyright (c) Marcin Kulik Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. rainbow-3.0.0/.rubocop_todo.yml0000644000004100000410000000135113312112606016475 0ustar www-datawww-data# This configuration was generated by # `rubocop --auto-gen-config` # on 2017-06-30 12:37:52 +0200 using RuboCop version 0.49.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. # Offense count: 1 Metrics/AbcSize: Max: 25 # Offense count: 1 Metrics/CyclomaticComplexity: Max: 9 # Offense count: 1 # Configuration parameters: CountComments. Metrics/MethodLength: Max: 23 # Offense count: 1 # Configuration parameters: CountComments. Metrics/ModuleLength: Max: 147 # Offense count: 1 Metrics/PerceivedComplexity: Max: 8 rainbow-3.0.0/Rakefile0000644000004100000410000000025113312112606014641 0ustar www-datawww-datarequire "bundler/gem_tasks" require 'rspec/core/rake_task' RSpec::Core::RakeTask.new require 'rubocop/rake_task' RuboCop::RakeTask.new task default: %i[spec rubocop] rainbow-3.0.0/lib/0000755000004100000410000000000013312112606013744 5ustar www-datawww-datarainbow-3.0.0/lib/rainbow/0000755000004100000410000000000013312112606015405 5ustar www-datawww-datarainbow-3.0.0/lib/rainbow/refinement.rb0000644000004100000410000000043313312112606020066 0ustar www-datawww-datarequire_relative 'presenter' require_relative 'global' module Rainbow refine String do Presenter.instance_methods(false).each do |method_name| define_method(method_name) do |*args| ::Rainbow.global.wrap(self).send(method_name, *args) end end end end rainbow-3.0.0/lib/rainbow/version.rb0000644000004100000410000000005613312112606017420 0ustar www-datawww-datamodule Rainbow VERSION = "3.0.0".freeze end rainbow-3.0.0/lib/rainbow/string_utils.rb0000644000004100000410000000106313312112606020460 0ustar www-datawww-datamodule Rainbow class StringUtils def self.wrap_with_sgr(string, codes) return string if codes.empty? seq = "\e[" + codes.join(";") + "m" match = string.match(/^(\e\[([\d;]+)m)*/) seq_pos = match.end(0) string = string[0...seq_pos] + seq + string[seq_pos..-1] string += "\e[0m" unless string =~ /\e\[0m$/ string end def self.uncolor(string) # See http://www.commandlinefu.com/commands/view/3584/remove-color-codes-special-characters-with-sed string.gsub(/\e\[[0-9;]*m/, '') end end end rainbow-3.0.0/lib/rainbow/x11_color_names.rb0000644000004100000410000001134013312112606020723 0ustar www-datawww-datamodule Rainbow module X11ColorNames NAMES = { aqua: [0, 255, 255], aquamarine: [127, 255, 212], mediumaquamarine: [102, 205, 170], azure: [240, 255, 255], beige: [245, 245, 220], bisque: [255, 228, 196], black: [0, 0, 0], blanchedalmond: [255, 235, 205], blue: [0, 0, 255], darkblue: [0, 0, 139], lightblue: [173, 216, 230], mediumblue: [0, 0, 205], aliceblue: [240, 248, 255], cadetblue: [95, 158, 160], dodgerblue: [30, 144, 255], midnightblue: [25, 25, 112], navyblue: [0, 0, 128], powderblue: [176, 224, 230], royalblue: [65, 105, 225], skyblue: [135, 206, 235], deepskyblue: [0, 191, 255], lightskyblue: [135, 206, 250], slateblue: [106, 90, 205], darkslateblue: [72, 61, 139], mediumslateblue: [123, 104, 238], steelblue: [70, 130, 180], lightsteelblue: [176, 196, 222], brown: [165, 42, 42], rosybrown: [188, 143, 143], saddlebrown: [139, 69, 19], sandybrown: [244, 164, 96], burlywood: [222, 184, 135], chartreuse: [127, 255, 0], chocolate: [210, 105, 30], coral: [255, 127, 80], lightcoral: [240, 128, 128], cornflower: [100, 149, 237], cornsilk: [255, 248, 220], crimson: [220, 20, 60], cyan: [0, 255, 255], darkcyan: [0, 139, 139], lightcyan: [224, 255, 255], firebrick: [178, 34, 34], fuchsia: [255, 0, 255], gainsboro: [220, 220, 220], gold: [255, 215, 0], goldenrod: [218, 165, 32], darkgoldenrod: [184, 134, 11], lightgoldenrod: [250, 250, 210], palegoldenrod: [238, 232, 170], gray: [190, 190, 190], darkgray: [169, 169, 169], dimgray: [105, 105, 105], lightgray: [211, 211, 211], slategray: [112, 128, 144], lightslategray: [119, 136, 153], webgray: [128, 128, 128], green: [0, 255, 0], darkgreen: [0, 100, 0], lightgreen: [144, 238, 144], palegreen: [152, 251, 152], darkolivegreen: [85, 107, 47], yellowgreen: [154, 205, 50], forestgreen: [34, 139, 34], lawngreen: [124, 252, 0], limegreen: [50, 205, 50], seagreen: [46, 139, 87], darkseagreen: [143, 188, 143], lightseagreen: [32, 178, 170], mediumseagreen: [60, 179, 113], springgreen: [0, 255, 127], mediumspringgreen: [0, 250, 154], webgreen: [0, 128, 0], honeydew: [240, 255, 240], indianred: [205, 92, 92], indigo: [75, 0, 130], ivory: [255, 255, 240], khaki: [240, 230, 140], darkkhaki: [189, 183, 107], lavender: [230, 230, 250], lavenderblush: [255, 240, 245], lemonchiffon: [255, 250, 205], lime: [0, 255, 0], linen: [250, 240, 230], magenta: [255, 0, 255], darkmagenta: [139, 0, 139], maroon: [176, 48, 96], webmaroon: [127, 0, 0], mintcream: [245, 255, 250], mistyrose: [255, 228, 225], moccasin: [255, 228, 181], oldlace: [253, 245, 230], olive: [128, 128, 0], olivedrab: [107, 142, 35], orange: [255, 165, 0], darkorange: [255, 140, 0], orchid: [218, 112, 214], darkorchid: [153, 50, 204], mediumorchid: [186, 85, 211], papayawhip: [255, 239, 213], peachpuff: [255, 218, 185], peru: [205, 133, 63], pink: [255, 192, 203], deeppink: [255, 20, 147], lightpink: [255, 182, 193], hotpink: [255, 105, 180], plum: [221, 160, 221], purple: [160, 32, 240], mediumpurple: [147, 112, 219], rebeccapurple: [102, 51, 153], webpurple: [127, 0, 127], red: [255, 0, 0], darkred: [139, 0, 0], orangered: [255, 69, 0], mediumvioletred: [199, 21, 133], palevioletred: [219, 112, 147], salmon: [250, 128, 114], darksalmon: [233, 150, 122], lightsalmon: [255, 160, 122], seashell: [255, 245, 238], sienna: [160, 82, 45], silver: [192, 192, 192], darkslategray: [47, 79, 79], snow: [255, 250, 250], tan: [210, 180, 140], teal: [0, 128, 128], thistle: [216, 191, 216], tomato: [255, 99, 71], turquoise: [64, 224, 208], darkturquoise: [0, 206, 209], mediumturquoise: [72, 209, 204], paleturquoise: [175, 238, 238], violet: [238, 130, 238], darkviolet: [148, 0, 211], blueviolet: [138, 43, 226], wheat: [245, 222, 179], white: [255, 255, 255], antiquewhite: [250, 235, 215], floralwhite: [255, 250, 240], ghostwhite: [248, 248, 255], navajowhite: [255, 222, 173], whitesmoke: [245, 245, 245], yellow: [255, 255, 0], lightyellow: [255, 255, 224], greenyellow: [173, 255, 47] }.freeze end end rainbow-3.0.0/lib/rainbow/color.rb0000644000004100000410000000632613312112606017057 0ustar www-datawww-datamodule Rainbow class Color attr_reader :ground def self.build(ground, values) unless [1, 3].include?(values.size) raise ArgumentError, "Wrong number of arguments for color definition, should be 1 or 3" end color = values.size == 1 ? values.first : values case color # NOTE: Properly handle versions before/after Ruby 2.4.0. # Ruby 2.4+ unifies Fixnum & Bignum into Integer. # However previous versions would still use Fixnum. # To avoid missing `Fixnum` input, call `0.class` which would # return either `Integer` or `Fixnum`. when 0.class Indexed.new(ground, color) when Symbol if Named.color_names.include?(color) Named.new(ground, color) elsif X11Named.color_names.include?(color) X11Named.new(ground, color) else raise ArgumentError, "Unknown color name, valid names: " + (Named.color_names + X11Named.color_names).join(', ') end when Array RGB.new(ground, *color) when String RGB.new(ground, *parse_hex_color(color)) end end def self.parse_hex_color(hex) hex = hex.sub(/^#/, '') r = hex[0..1].to_i(16) g = hex[2..3].to_i(16) b = hex[4..5].to_i(16) [r, g, b] end class Indexed < Color attr_reader :num def initialize(ground, num) @ground = ground @num = num end def codes code = num + (ground == :foreground ? 30 : 40) [code] end end class Named < Indexed NAMES = { black: 0, red: 1, green: 2, yellow: 3, blue: 4, magenta: 5, cyan: 6, white: 7, default: 9 }.freeze def self.color_names NAMES.keys end def self.valid_names color_names.join(', ') end def initialize(ground, name) unless Named.color_names.include?(name) raise ArgumentError, "Unknown color name, valid names: #{self.class.valid_names}" end super(ground, NAMES[name]) end end class RGB < Indexed attr_reader :r, :g, :b def self.to_ansi_domain(value) (6 * (value / 256.0)).to_i end def initialize(ground, *values) if values.min < 0 || values.max > 255 raise ArgumentError, "RGB value outside 0-255 range" end super(ground, 8) @r, @g, @b = values end def codes super + [5, code_from_rgb] end private def code_from_rgb 16 + self.class.to_ansi_domain(r) * 36 + self.class.to_ansi_domain(g) * 6 + self.class.to_ansi_domain(b) end end class X11Named < RGB include X11ColorNames def self.color_names NAMES.keys end def self.valid_names color_names.join(', ') end def initialize(ground, name) unless X11Named.color_names.include?(name) raise ArgumentError, "Unknown color name, valid names: #{self.class.valid_names}" end super(ground, *NAMES[name]) end end end end rainbow-3.0.0/lib/rainbow/wrapper.rb0000644000004100000410000000052713312112606017416 0ustar www-datawww-datarequire_relative 'presenter' require_relative 'null_presenter' module Rainbow class Wrapper attr_accessor :enabled def initialize(enabled = true) @enabled = enabled end def wrap(string) if enabled Presenter.new(string.to_s) else NullPresenter.new(string.to_s) end end end end rainbow-3.0.0/lib/rainbow/null_presenter.rb0000644000004100000410000000214513312112606020775 0ustar www-datawww-datamodule Rainbow class NullPresenter < ::String def color(*_values) self end def background(*_values) self end def reset self end def bright self end def faint self end def italic self end def underline self end def blink self end def inverse self end def hide self end def black self end def red self end def green self end def yellow self end def blue self end def magenta self end def cyan self end def white self end def method_missing(method_name, *args) if Color::X11Named.color_names.include?(method_name) && args.empty? self else super end end def respond_to_missing?(method_name, *args) Color::X11Named.color_names.include?(method_name) && args.empty? || super end alias foreground color alias fg color alias bg background alias bold bright alias dark faint end end rainbow-3.0.0/lib/rainbow/presenter.rb0000644000004100000410000000535513312112606017751 0ustar www-datawww-datarequire_relative 'string_utils' require_relative 'x11_color_names' require_relative 'color' module Rainbow class Presenter < ::String TERM_EFFECTS = { reset: 0, bright: 1, faint: 2, italic: 3, underline: 4, blink: 5, inverse: 7, hide: 8 }.freeze # Sets color of this text. def color(*values) wrap_with_sgr(Color.build(:foreground, values).codes) end alias foreground color alias fg color # Sets background color of this text. def background(*values) wrap_with_sgr(Color.build(:background, values).codes) end alias bg background # Resets terminal to default colors/backgrounds. # # It shouldn't be needed to use this method because all methods # append terminal reset code to end of string. def reset wrap_with_sgr(TERM_EFFECTS[:reset]) end # Turns on bright/bold for this text. def bright wrap_with_sgr(TERM_EFFECTS[:bright]) end alias bold bright # Turns on faint/dark for this text (not well supported by terminal # emulators). def faint wrap_with_sgr(TERM_EFFECTS[:faint]) end alias dark faint # Turns on italic style for this text (not well supported by terminal # emulators). def italic wrap_with_sgr(TERM_EFFECTS[:italic]) end # Turns on underline decoration for this text. def underline wrap_with_sgr(TERM_EFFECTS[:underline]) end # Turns on blinking attribute for this text (not well supported by terminal # emulators). def blink wrap_with_sgr(TERM_EFFECTS[:blink]) end # Inverses current foreground/background colors. def inverse wrap_with_sgr(TERM_EFFECTS[:inverse]) end # Hides this text (set its color to the same as background). def hide wrap_with_sgr(TERM_EFFECTS[:hide]) end def black color(:black) end def red color(:red) end def green color(:green) end def yellow color(:yellow) end def blue color(:blue) end def magenta color(:magenta) end def cyan color(:cyan) end def white color(:white) end # We take care of X11 color method call here. # Such as #aqua, #ghostwhite. def method_missing(method_name, *args) if Color::X11Named.color_names.include?(method_name) && args.empty? color(method_name) else super end end def respond_to_missing?(method_name, *args) Color::X11Named.color_names.include?(method_name) && args.empty? || super end private def wrap_with_sgr(codes) #:nodoc: self.class.new(StringUtils.wrap_with_sgr(self, [*codes])) end end end rainbow-3.0.0/lib/rainbow/global.rb0000644000004100000410000000051313312112606017171 0ustar www-datawww-datarequire_relative 'wrapper' module Rainbow def self.global @global ||= Wrapper.new end def self.enabled global.enabled end def self.enabled=(value) global.enabled = value end def self.uncolor(string) StringUtils.uncolor(string) end end def Rainbow(string) Rainbow.global.wrap(string.to_s) end rainbow-3.0.0/lib/rainbow/ext/0000755000004100000410000000000013312112606016205 5ustar www-datawww-datarainbow-3.0.0/lib/rainbow/ext/string.rb0000644000004100000410000000163513312112606020045 0ustar www-datawww-datarequire 'rainbow' module Rainbow module Ext module String module InstanceMethods def foreground(*color) Rainbow(self).foreground(*color) end alias color foreground alias colour foreground def background(*color) Rainbow(self).background(*color) end def reset Rainbow(self).reset end def bright Rainbow(self).bright end def faint Rainbow(self).faint end def italic Rainbow(self).italic end def underline Rainbow(self).underline end def blink Rainbow(self).blink end def inverse Rainbow(self).inverse end def hide Rainbow(self).hide end end end end end ::String.send(:include, Rainbow::Ext::String::InstanceMethods) rainbow-3.0.0/lib/rainbow.rb0000644000004100000410000000041313312112606015730 0ustar www-datawww-datarequire_relative 'rainbow/global' module Rainbow def self.new Wrapper.new(global.enabled) end self.enabled = false unless STDOUT.tty? && STDERR.tty? self.enabled = false if ENV['TERM'] == 'dumb' self.enabled = true if ENV['CLICOLOR_FORCE'] == '1' end rainbow-3.0.0/Guardfile0000644000004100000410000000035313312112606015024 0ustar www-datawww-data# A sample Guardfile # More info at https://github.com/guard/guard#readme guard :rspec, cmd: 'rspec --color' do watch(%r{^spec/.+_spec\.rb$}) watch(%r{^lib/(.+)\.rb$}) { "spec" } watch('spec/spec_helper.rb') { "spec" } end rainbow-3.0.0/README.markdown0000644000004100000410000001766113312112606015712 0ustar www-datawww-data# Rainbow [![Gem Version](https://badge.fury.io/rb/rainbow.svg)](https://rubygems.org/gems/rainbow) [![Build Status](https://travis-ci.org/sickill/rainbow.svg?branch=master)](https://travis-ci.org/sickill/rainbow) [![Build status](https://ci.appveyor.com/api/projects/status/vq4acb2c38642s5q?svg=true)](https://ci.appveyor.com/project/sickill/rainbow) [![Code Climate](https://codeclimate.com/github/sickill/rainbow.svg)](https://codeclimate.com/github/sickill/rainbow) [![Coverage Status](https://coveralls.io/repos/sickill/rainbow/badge.svg)](https://coveralls.io/r/sickill/rainbow) Rainbow is a ruby gem for colorizing printed text on ANSI terminals. It provides a string presenter object, which adds several methods to your strings for wrapping them in [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code). These codes when printed in a terminal change text attributes like text color, background color, intensity etc. ## Usage To make your string colored wrap it with `Rainbow()` presenter and call `.color()` on it. ### Example ```ruby require 'rainbow' puts Rainbow("this is red").red + " and " + Rainbow("this on yellow bg").bg(:yellow) + " and " + Rainbow("even bright underlined!").underline.bright # => "\e[31mthis is red\e[0m and \e[43mthis on yellow bg\e[0m and \e[4m\e[1meven bright underlined!\e[0m" ``` Or, [watch this video example](https://asciinema.org/a/J928KpHoUQ0sl54ulOSOLE71E?rows=20&speed=2.5) ### Rainbow presenter API Rainbow presenter adds the following methods to presented string: * `color(c)` (with `foreground`, and `fg` aliases) * `background(c)` (with `bg` alias) * `bright` * `underline` * `blink` * `inverse` * `hide` * `faint` (not well supported by terminal emulators) * `italic` (not well supported by terminal emulators) Text color can also be changed by calling a method named by a color: * `black` * `red` * `green` * `yellow` * `blue` * `magenta` * `cyan` * `white` * `aqua` * `silver` * `aliceblue` * `indianred` All of the methods return `self` (the presenter object) so you can chain method calls: ```ruby Rainbow("hola!").blue.bright.underline ``` ### Refinement If you want to use the Refinements version, you can: ```ruby require 'rainbow/refinement' using Rainbow puts "Hi!".green ``` Here's an IRB session example: ``` >> 'Hello, World!'.blue.bright.underline NoMethodError: undefined method `blue' for "Hello, World!":String (ripl):1:in `
' >> using Rainbow => main >> 'Hello, World!'.blue.bright.underline => "\e[34m\e[1m\e[4mHello, World!\e[0m" ``` ### Color specification Both `color` and `background` accept color specified in any of the following ways: * ANSI color number (where 0 is black, 1 is red, 2 is green and so on): `Rainbow("hello").color(1)` * [ANSI color](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors) name or [X11 color](https://en.wikipedia.org/wiki/X11_color_names) name as a symbol: `Rainbow("hello").color(:yellow)`. This can be simplified to `Rainbow("hello").yellow` See [Color list](#user-content-color-list) for all available color names. Note that ANSI colors can be changed in accordance with terminal setting. But X11 color is just a syntax sugar for RGB triplet. So you always see what you specified. * RGB triplet as separate values in the range 0-255: `Rainbow("hello").color(115, 23, 98)` * RGB triplet as a hex string: `Rainbow("hello").color("FFC482")` or `Rainbow("hello").color("#FFC482")` When you specify a color with a RGB triplet rainbow finds the nearest match from 256 colors palette. Note that it requires a 256-colors capable terminal to display correctly. #### Example: Choose a random color You can pick a random color with Rainbow, it's a one-liner: ```ruby colors = Range.new(0,7).to_a "whoop dee doop".chars.map { |char| Rainbow(char).color(colors.sample) }.join # => "\e[36mw\e[0m\e[37mh\e[0m\e[34mo\e[0m\e[34mo\e[0m\e[37mp\e[0m\e[34m \e[0m\e[36md\e[0m\e[33me\e[0m\e[34me\e[0m\e[37m \e[0m\e[32md\e[0m\e[35mo\e[0m\e[33mo\e[0m\e[36mp\e[0m" colors = [:aliceblue, :antiquewhite, :aqua, :aquamarine, :azure, :beige, :bisque, :blanchedalmond, :blueviolet] "whoop dee doop".chars.map { |char| Rainbow(char).color(colors.sample) }.join # => "\e[38;5;135mw\e[0m\e[38;5;230mh\e[0m\e[38;5;231mo\e[0m\e[38;5;135mo\e[0m\e[38;5;231mp\e[0m\e[38;5;231m \e[0m\e[38;5;122md\e[0m\e[38;5;231me\e[0m\e[38;5;231me\e[0m\e[38;5;230m \e[0m\e[38;5;122md\e[0m\e[38;5;51mo\e[0m\e[38;5;51mo\e[0m\e[38;5;51mp\e[0m" ``` ### Configuration Rainbow can be enabled/disabled globally by setting: ```ruby Rainbow.enabled = true/false ``` When disabled all the methods return an unmodified string (`Rainbow("hello").red == "hello"`). It's enabled by default, unless STDOUT/STDERR is not a TTY or a terminal is dumb. ### Advanced usage `Rainbow()` and `Rainbow.enabled` operate on the global Rainbow wrapper instance. If you would like to selectively enable/disable coloring in separate parts of your application you can get a new Rainbow wrapper instance for each of them and control the state of coloring during the runtime. ```ruby rainbow_one = Rainbow.new rainbow_two = Rainbow.new rainbow_one.enabled = false Rainbow("hello").red # => "\e[31mhello\e[0m" ("hello" if not on TTY) rainbow_one.wrap("hello").red # => "hello" rainbow_two.wrap("hello").red # => "\e[31mhello\e[0m" ("hello" if not on TTY) ``` By default each new instance inherits enabled/disabled state from the global `Rainbow.enabled`. This feature comes handy for example when you have multiple output formatters in your application and some of them print to a terminal but others write to a file. Normally rainbow would detect that STDIN/STDERR is a TTY and would colorize all the strings, even the ones that go through file writing formatters. You can easily solve that by disabling coloring for the Rainbow instances that are used by formatters with file output. ## Installation Add it to your Gemfile: ```ruby gem 'rainbow' ``` Or just install it via rubygems: ```ruby gem install rainbow ``` ## Color list ### ANSI colors `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white` ### X11 colors `aliceblue`, `antiquewhite`, `aqua`, `aquamarine`, `azure`, `beige`, `bisque`, `blanchedalmond`, `blueviolet`, `brown`, `burlywood`, `cadetblue`, `chartreuse`, `chocolate`, `coral`, `cornflower`, `cornsilk`, `crimson`, `darkblue`, `darkcyan`, `darkgoldenrod`, `darkgray`, `darkgreen`, `darkkhaki`, `darkmagenta`, `darkolivegreen`, `darkorange`, `darkorchid`, `darkred`, `darksalmon`, `darkseagreen`, `darkslateblue`, `darkslategray`, `darkturquoise`, `darkviolet`, `deeppink`, `deepskyblue`, `dimgray`, `dodgerblue`, `firebrick`, `floralwhite`, `forestgreen`, `fuchsia`, `gainsboro`, `ghostwhite`, `gold`, `goldenrod`, `gray`, `greenyellow`, `honeydew`, `hotpink`, `indianred`, `indigo`, `ivory`, `khaki`, `lavender`, `lavenderblush`, `lawngreen`, `lemonchiffon`, `lightblue`, `lightcoral`, `lightcyan`, `lightgoldenrod`, `lightgray`, `lightgreen`, `lightpink`, `lightsalmon`, `lightseagreen`, `lightskyblue`, `lightslategray`, `lightsteelblue`, `lightyellow`, `lime`, `limegreen`, `linen`, `maroon`, `mediumaquamarine`, `mediumblue`, `mediumorchid`, `mediumpurple`, `mediumseagreen`, `mediumslateblue`, `mediumspringgreen`, `mediumturquoise`, `mediumvioletred`, `midnightblue`, `mintcream`, `mistyrose`, `moccasin`, `navajowhite`, `navyblue`, `oldlace`, `olive`, `olivedrab`, `orange`, `orangered`, `orchid`, `palegoldenrod`, `palegreen`, `paleturquoise`, `palevioletred`, `papayawhip`, `peachpuff`, `peru`, `pink`, `plum`, `powderblue`, `purple`, `rebeccapurple`, `rosybrown`, `royalblue`, `saddlebrown`, `salmon`, `sandybrown`, `seagreen`, `seashell`, `sienna`, `silver`, `skyblue`, `slateblue`, `slategray`, `snow`, `springgreen`, `steelblue`, `tan`, `teal`, `thistle`, `tomato`, `turquoise`, `violet`, `webgray`, `webgreen`, `webmaroon`, `webpurple`, `wheat`, `whitesmoke`, `yellowgreen` ## Authors [Marcin Kulik](http://ku1ik.com/) and [great open-source contributors](https://github.com/sickill/rainbow/graphs/contributors). rainbow-3.0.0/Gemfile0000644000004100000410000000051713312112606014474 0ustar www-datawww-datasource 'https://rubygems.org' gemspec gem 'rake' group :test do gem 'coveralls', require: false gem 'rspec' end group :development do gem 'mutant-rspec' end group :test, :development do gem 'rubocop', '~> 0.51.0' end group :guard do gem 'guard' gem 'guard-rspec' end platform :rbx do gem 'json' gem 'rubysl' end rainbow-3.0.0/appveyor.yml0000644000004100000410000000113113312112606015562 0ustar www-datawww-data--- version: "{build}" install: - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH% - bundle config --local path vendor/bundle - bundle install --jobs 3 --retry 3 --without guard development build: off cache: - vendor/bundle init: - git config --global core.autocrlf true before_test: - ruby -v - gem -v - bundle -v test_script: - bundle exec rake environment: matrix: - RUBY_VERSION: 21 - RUBY_VERSION: 21-x64 - RUBY_VERSION: 22 - RUBY_VERSION: 22-x64 - RUBY_VERSION: 23 - RUBY_VERSION: 23-x64 matrix: fast_finish: true branches: only: - master rainbow-3.0.0/rainbow.gemspec0000644000004100000410000000167213312112606016212 0ustar www-datawww-datalib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'rainbow/version' Gem::Specification.new do |spec| spec.name = "rainbow" spec.version = Rainbow::VERSION spec.authors = ["Marcin Kulik", "Olle Jonsson"] spec.email = ["m@ku1ik.com"] spec.description = 'Colorize printed text on ANSI terminals' spec.summary = 'Colorize printed text on ANSI terminals' spec.homepage = "https://github.com/sickill/rainbow" spec.license = "MIT" spec.required_ruby_version = '>= 2.1.0' spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR) spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] spec.add_development_dependency "bundler", "~> 1.3" end rainbow-3.0.0/Changelog.md0000644000004100000410000000377513312112606015423 0ustar www-datawww-data# Rainbow changelog ## 3.0.0 (2017-10-24) * dropped MRI 1.9.3 compatibility * dropped MRI 2.0 compatibility * removed rake dependency ## 2.2.2 (2017-04-21) * added explicit rake dependency to fix installation issue ## 2.2.1 (2016-12-28) * fixed gem installation (2.2.0 was a broken release) ## 2.2.0 (2016-12-27) * improved Windows support * added Ruby 2.4 support * added `bold` alias method for `bright` ## 2.1.0 (2016-01-24) * added X11 color support * fixed `require` issue when rainbow is used as a dependency in another gem * improved Windows support ## 2.0.0 (2014-01-24) * disable string mixin by default ## 1.99.2 (2014-01-24) * bring back ruby 1.8 support ## 1.99.1 (2013-12-28) * drop support for ruby 1.8 * `require "rainbow/string"` -> `require "rainbow/ext/string"` * custom rainbow wrapper instances (with separate enabled/disabled state) * shortcut methods for changing text color (`Rainbow("foo").red`) ## 1.99.0 (2013-12-26) * preparation for dropping String monkey patching * `require "rainbow/string"` if you want to use monkey patched String * introduction of Rainbow() wrapper * support for MRI 1.8.7, 1.9.2, 1.9.3, 2.0 and 2.1, JRuby and Rubinius * deprecation of Sickill::Rainbow namespace (use Rainbow.enabled = true instead) ## 1.1.4 (2012-4-28) * option for forcing coloring even when STDOUT is not a TTY (CLICOLOR_FORCE env var) * fix for frozen strings ## 1.1.3 (2011-12-6) * improved compatibility with MRI 1.8.7 * fix for regression with regards to original string mutation ## 1.1.2 (2011-11-13) * improved compatibility with MRI 1.9.3 ## 1.1.1 (2011-2-7) * improved Windows support ## 1.1 (2010-6-7) * option for enabling/disabling of escape code wrapping * auto-disabling when STDOUT is not a TTY ## 1.0.4 (2009-11-27) * support for 256 colors ## 1.0.3 (2009-7-26) * rainbow methods don't mutate the original string object anymore ## 1.0.2 (2009-5-15) * improved support for ruby 1.8.6 and 1.9.1 ## 1.0.1 (2009-3-19) * Windows support ## 1.0.0 (2008-7-21) * initial version