rainbow 3.0.0 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Changelog.md +10 -2
- data/README.markdown +3 -0
- data/lib/rainbow/color.rb +15 -8
- data/lib/rainbow/ext/string.rb +11 -1
- data/lib/rainbow/global.rb +2 -0
- data/lib/rainbow/null_presenter.rb +7 -0
- data/lib/rainbow/presenter.rb +16 -7
- data/lib/rainbow/refinement.rb +2 -0
- data/lib/rainbow/string_utils.rb +6 -5
- data/lib/rainbow/version.rb +3 -1
- data/lib/rainbow/wrapper.rb +2 -0
- data/lib/rainbow/x11_color_names.rb +2 -0
- data/lib/rainbow.rb +2 -0
- metadata +16 -44
- data/.gitignore +0 -17
- data/.rubocop.yml +0 -20
- data/.rubocop_todo.yml +0 -29
- data/.travis.yml +0 -24
- data/Gemfile +0 -28
- data/Guardfile +0 -8
- data/Rakefile +0 -9
- data/appveyor.yml +0 -40
- data/rainbow.gemspec +0 -22
- data/spec/integration/instance_spec.rb +0 -33
- data/spec/integration/rainbow_spec.rb +0 -157
- data/spec/integration/refinement_spec.rb +0 -36
- data/spec/integration/string_spec.rb +0 -81
- data/spec/integration/uncolor_spec.rb +0 -14
- data/spec/spec_helper.rb +0 -10
- data/spec/support/presenter_shared_examples.rb +0 -9
- data/spec/unit/color_spec.rb +0 -296
- data/spec/unit/null_presenter_spec.rb +0 -110
- data/spec/unit/presenter_spec.rb +0 -199
- data/spec/unit/string_utils_spec.rb +0 -94
- data/spec/unit/wrapper_spec.rb +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7367f9386ef2460491f123bd207091956c6dcce6300dcf3957a48c126a1ec900
|
4
|
+
data.tar.gz: 1c123ecd4c6ee30422ff9df560df3ec4f5d4c8bcb6010e3a0c5be4435848894a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64ddf54fa7edd4f0f05301270503025bfb63cbca6db7e940b4cf6c62cbd860b3cf939c885f5e69becd1f4faf39c9d2fe1e8a35597dd28fe1b30df26e52f334f0
|
7
|
+
data.tar.gz: 74550a67235dcca95dbd6404023576843e626e0ec00e557c0e38fbd145f778983b6c63136008d39da958a4fc83dc73e7a62758a40c8ead76c24066e968b66b6e
|
data/Changelog.md
CHANGED
@@ -1,10 +1,18 @@
|
|
1
1
|
# Rainbow changelog
|
2
2
|
|
3
|
-
## 3.
|
3
|
+
## 3.1.0 (2020-08-26)
|
4
4
|
|
5
|
+
- added `cross_out` aka `strike`
|
6
|
+
- hexadecimal color names supported better, see #83
|
7
|
+
- gemspec: list files using a Ruby expression, avoiding git
|
8
|
+
|
9
|
+
## 3.0.0 (2017-11-29)
|
10
|
+
|
11
|
+
* added String refinement
|
12
|
+
* added new `Rainbow.uncolor` method
|
5
13
|
* dropped MRI 1.9.3 compatibility
|
6
14
|
* dropped MRI 2.0 compatibility
|
7
|
-
* removed
|
15
|
+
* removed Rake dependency
|
8
16
|
|
9
17
|
## 2.2.2 (2017-04-21)
|
10
18
|
|
data/README.markdown
CHANGED
@@ -29,6 +29,8 @@ puts Rainbow("this is red").red + " and " + Rainbow("this on yellow bg").bg(:yel
|
|
29
29
|
# => "\e[31mthis is red\e[0m and \e[43mthis on yellow bg\e[0m and \e[4m\e[1meven bright underlined!\e[0m"
|
30
30
|
```
|
31
31
|
|
32
|
+
![Screenshot of the previous code in a terminal](https://user-images.githubusercontent.com/132/132943811-93747cc5-bdaf-43a2-a1a4-a1f18e805eba.png)
|
33
|
+
|
32
34
|
Or, [watch this video example](https://asciinema.org/a/J928KpHoUQ0sl54ulOSOLE71E?rows=20&speed=2.5)
|
33
35
|
|
34
36
|
### Rainbow presenter API
|
@@ -44,6 +46,7 @@ Rainbow presenter adds the following methods to presented string:
|
|
44
46
|
* `hide`
|
45
47
|
* `faint` (not well supported by terminal emulators)
|
46
48
|
* `italic` (not well supported by terminal emulators)
|
49
|
+
* `cross_out`, `strike`
|
47
50
|
|
48
51
|
Text color can also be changed by calling a method named by a color:
|
49
52
|
|
data/lib/rainbow/color.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Rainbow
|
2
4
|
class Color
|
3
5
|
attr_reader :ground
|
@@ -36,6 +38,11 @@ module Rainbow
|
|
36
38
|
end
|
37
39
|
|
38
40
|
def self.parse_hex_color(hex)
|
41
|
+
unless hex =~ /^#?[a-f0-9]{6}/i
|
42
|
+
raise ArgumentError,
|
43
|
+
"Invalid hexadecimal RGB triplet. Valid format: /^#?[a-f0-9]{6}/i"
|
44
|
+
end
|
45
|
+
|
39
46
|
hex = hex.sub(/^#/, '')
|
40
47
|
r = hex[0..1].to_i(16)
|
41
48
|
g = hex[2..3].to_i(16)
|
@@ -61,14 +68,14 @@ module Rainbow
|
|
61
68
|
|
62
69
|
class Named < Indexed
|
63
70
|
NAMES = {
|
64
|
-
black:
|
65
|
-
red:
|
66
|
-
green:
|
67
|
-
yellow:
|
68
|
-
blue:
|
71
|
+
black: 0,
|
72
|
+
red: 1,
|
73
|
+
green: 2,
|
74
|
+
yellow: 3,
|
75
|
+
blue: 4,
|
69
76
|
magenta: 5,
|
70
|
-
cyan:
|
71
|
-
white:
|
77
|
+
cyan: 6,
|
78
|
+
white: 7,
|
72
79
|
default: 9
|
73
80
|
}.freeze
|
74
81
|
|
@@ -98,7 +105,7 @@ module Rainbow
|
|
98
105
|
end
|
99
106
|
|
100
107
|
def initialize(ground, *values)
|
101
|
-
if values.min
|
108
|
+
if values.min.negative? || values.max > 255
|
102
109
|
raise ArgumentError, "RGB value outside 0-255 range"
|
103
110
|
end
|
104
111
|
|
data/lib/rainbow/ext/string.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rainbow'
|
2
4
|
|
3
5
|
module Rainbow
|
@@ -46,9 +48,17 @@ module Rainbow
|
|
46
48
|
def hide
|
47
49
|
Rainbow(self).hide
|
48
50
|
end
|
51
|
+
|
52
|
+
def cross_out
|
53
|
+
Rainbow(self).cross_out
|
54
|
+
end
|
55
|
+
|
56
|
+
alias strike cross_out
|
49
57
|
end
|
50
58
|
end
|
51
59
|
end
|
52
60
|
end
|
53
61
|
|
54
|
-
|
62
|
+
class String
|
63
|
+
include Rainbow::Ext::String::InstanceMethods
|
64
|
+
end
|
data/lib/rainbow/global.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Rainbow
|
2
4
|
class NullPresenter < ::String
|
3
5
|
def color(*_values)
|
@@ -40,6 +42,10 @@ module Rainbow
|
|
40
42
|
self
|
41
43
|
end
|
42
44
|
|
45
|
+
def cross_out
|
46
|
+
self
|
47
|
+
end
|
48
|
+
|
43
49
|
def black
|
44
50
|
self
|
45
51
|
end
|
@@ -89,5 +95,6 @@ module Rainbow
|
|
89
95
|
alias bg background
|
90
96
|
alias bold bright
|
91
97
|
alias dark faint
|
98
|
+
alias strike cross_out
|
92
99
|
end
|
93
100
|
end
|
data/lib/rainbow/presenter.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'string_utils'
|
2
4
|
require_relative 'x11_color_names'
|
3
5
|
require_relative 'color'
|
@@ -5,14 +7,15 @@ require_relative 'color'
|
|
5
7
|
module Rainbow
|
6
8
|
class Presenter < ::String
|
7
9
|
TERM_EFFECTS = {
|
8
|
-
reset:
|
9
|
-
bright:
|
10
|
-
faint:
|
11
|
-
italic:
|
10
|
+
reset: 0,
|
11
|
+
bright: 1,
|
12
|
+
faint: 2,
|
13
|
+
italic: 3,
|
12
14
|
underline: 4,
|
13
|
-
blink:
|
14
|
-
inverse:
|
15
|
-
hide:
|
15
|
+
blink: 5,
|
16
|
+
inverse: 7,
|
17
|
+
hide: 8,
|
18
|
+
cross_out: 9
|
16
19
|
}.freeze
|
17
20
|
|
18
21
|
# Sets color of this text.
|
@@ -80,6 +83,12 @@ module Rainbow
|
|
80
83
|
wrap_with_sgr(TERM_EFFECTS[:hide])
|
81
84
|
end
|
82
85
|
|
86
|
+
def cross_out
|
87
|
+
wrap_with_sgr(TERM_EFFECTS[:cross_out])
|
88
|
+
end
|
89
|
+
|
90
|
+
alias strike cross_out
|
91
|
+
|
83
92
|
def black
|
84
93
|
color(:black)
|
85
94
|
end
|
data/lib/rainbow/refinement.rb
CHANGED
data/lib/rainbow/string_utils.rb
CHANGED
@@ -1,16 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Rainbow
|
2
4
|
class StringUtils
|
3
5
|
def self.wrap_with_sgr(string, codes)
|
4
6
|
return string if codes.empty?
|
5
7
|
|
6
8
|
seq = "\e[" + codes.join(";") + "m"
|
7
|
-
match = string.match(/^(\e\[([\d;]+)m)*/)
|
8
|
-
seq_pos = match.end(0)
|
9
|
-
string = string[0...seq_pos] + seq + string[seq_pos..-1]
|
10
9
|
|
11
|
-
string
|
10
|
+
string = string.sub(/^(\e\[([\d;]+)m)*/) { |m| m + seq }
|
11
|
+
|
12
|
+
return string if string.end_with? "\e[0m"
|
12
13
|
|
13
|
-
string
|
14
|
+
string + "\e[0m"
|
14
15
|
end
|
15
16
|
|
16
17
|
def self.uncolor(string)
|
data/lib/rainbow/version.rb
CHANGED
data/lib/rainbow/wrapper.rb
CHANGED
data/lib/rainbow.rb
CHANGED
metadata
CHANGED
@@ -1,30 +1,36 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rainbow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcin Kulik
|
8
8
|
- Olle Jonsson
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-01-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '1.3'
|
21
|
+
- - "<"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '3'
|
21
24
|
type: :development
|
22
25
|
prerelease: false
|
23
26
|
version_requirements: !ruby/object:Gem::Requirement
|
24
27
|
requirements:
|
25
|
-
- - "
|
28
|
+
- - ">="
|
26
29
|
- !ruby/object:Gem::Version
|
27
30
|
version: '1.3'
|
31
|
+
- - "<"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3'
|
28
34
|
description: Colorize printed text on ANSI terminals
|
29
35
|
email:
|
30
36
|
- m@ku1ik.com
|
@@ -32,17 +38,9 @@ executables: []
|
|
32
38
|
extensions: []
|
33
39
|
extra_rdoc_files: []
|
34
40
|
files:
|
35
|
-
- ".gitignore"
|
36
|
-
- ".rubocop.yml"
|
37
|
-
- ".rubocop_todo.yml"
|
38
|
-
- ".travis.yml"
|
39
41
|
- Changelog.md
|
40
|
-
- Gemfile
|
41
|
-
- Guardfile
|
42
42
|
- LICENSE
|
43
43
|
- README.markdown
|
44
|
-
- Rakefile
|
45
|
-
- appveyor.yml
|
46
44
|
- lib/rainbow.rb
|
47
45
|
- lib/rainbow/color.rb
|
48
46
|
- lib/rainbow/ext/string.rb
|
@@ -54,24 +52,11 @@ files:
|
|
54
52
|
- lib/rainbow/version.rb
|
55
53
|
- lib/rainbow/wrapper.rb
|
56
54
|
- lib/rainbow/x11_color_names.rb
|
57
|
-
- rainbow.gemspec
|
58
|
-
- spec/integration/instance_spec.rb
|
59
|
-
- spec/integration/rainbow_spec.rb
|
60
|
-
- spec/integration/refinement_spec.rb
|
61
|
-
- spec/integration/string_spec.rb
|
62
|
-
- spec/integration/uncolor_spec.rb
|
63
|
-
- spec/spec_helper.rb
|
64
|
-
- spec/support/presenter_shared_examples.rb
|
65
|
-
- spec/unit/color_spec.rb
|
66
|
-
- spec/unit/null_presenter_spec.rb
|
67
|
-
- spec/unit/presenter_spec.rb
|
68
|
-
- spec/unit/string_utils_spec.rb
|
69
|
-
- spec/unit/wrapper_spec.rb
|
70
55
|
homepage: https://github.com/sickill/rainbow
|
71
56
|
licenses:
|
72
57
|
- MIT
|
73
58
|
metadata: {}
|
74
|
-
post_install_message:
|
59
|
+
post_install_message:
|
75
60
|
rdoc_options: []
|
76
61
|
require_paths:
|
77
62
|
- lib
|
@@ -79,28 +64,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
79
64
|
requirements:
|
80
65
|
- - ">="
|
81
66
|
- !ruby/object:Gem::Version
|
82
|
-
version: 2.
|
67
|
+
version: 2.3.0
|
83
68
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
69
|
requirements:
|
85
70
|
- - ">="
|
86
71
|
- !ruby/object:Gem::Version
|
87
72
|
version: '0'
|
88
73
|
requirements: []
|
89
|
-
|
90
|
-
|
91
|
-
signing_key:
|
74
|
+
rubygems_version: 3.0.9
|
75
|
+
signing_key:
|
92
76
|
specification_version: 4
|
93
77
|
summary: Colorize printed text on ANSI terminals
|
94
|
-
test_files:
|
95
|
-
- spec/integration/instance_spec.rb
|
96
|
-
- spec/integration/rainbow_spec.rb
|
97
|
-
- spec/integration/refinement_spec.rb
|
98
|
-
- spec/integration/string_spec.rb
|
99
|
-
- spec/integration/uncolor_spec.rb
|
100
|
-
- spec/spec_helper.rb
|
101
|
-
- spec/support/presenter_shared_examples.rb
|
102
|
-
- spec/unit/color_spec.rb
|
103
|
-
- spec/unit/null_presenter_spec.rb
|
104
|
-
- spec/unit/presenter_spec.rb
|
105
|
-
- spec/unit/string_utils_spec.rb
|
106
|
-
- spec/unit/wrapper_spec.rb
|
78
|
+
test_files: []
|
data/.gitignore
DELETED
data/.rubocop.yml
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
inherit_from: .rubocop_todo.yml
|
2
|
-
|
3
|
-
AllCops:
|
4
|
-
DisplayCopNames: true
|
5
|
-
DisplayStyleGuide: true
|
6
|
-
TargetRubyVersion: "2.1"
|
7
|
-
Exclude:
|
8
|
-
- "spec/**/*"
|
9
|
-
- "vendor/**/*"
|
10
|
-
Documentation:
|
11
|
-
Enabled: false
|
12
|
-
|
13
|
-
HashSyntax:
|
14
|
-
Enabled: false
|
15
|
-
|
16
|
-
MethodName:
|
17
|
-
Enabled: false
|
18
|
-
|
19
|
-
StringLiterals:
|
20
|
-
Enabled: false
|
data/.rubocop_todo.yml
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# This configuration was generated by
|
2
|
-
# `rubocop --auto-gen-config`
|
3
|
-
# on 2017-06-30 12:37:52 +0200 using RuboCop version 0.49.1.
|
4
|
-
# The point is for the user to remove these configuration records
|
5
|
-
# one by one as the offenses are removed from the code base.
|
6
|
-
# Note that changes in the inspected code, or installation of new
|
7
|
-
# versions of RuboCop, may require this file to be generated again.
|
8
|
-
|
9
|
-
# Offense count: 1
|
10
|
-
Metrics/AbcSize:
|
11
|
-
Max: 25
|
12
|
-
|
13
|
-
# Offense count: 1
|
14
|
-
Metrics/CyclomaticComplexity:
|
15
|
-
Max: 9
|
16
|
-
|
17
|
-
# Offense count: 1
|
18
|
-
# Configuration parameters: CountComments.
|
19
|
-
Metrics/MethodLength:
|
20
|
-
Max: 23
|
21
|
-
|
22
|
-
# Offense count: 1
|
23
|
-
# Configuration parameters: CountComments.
|
24
|
-
Metrics/ModuleLength:
|
25
|
-
Max: 147
|
26
|
-
|
27
|
-
# Offense count: 1
|
28
|
-
Metrics/PerceivedComplexity:
|
29
|
-
Max: 8
|
data/.travis.yml
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
cache:
|
3
|
-
bundler: true
|
4
|
-
|
5
|
-
before_install:
|
6
|
-
- gem install bundler
|
7
|
-
|
8
|
-
bundler_args: --without guard development
|
9
|
-
|
10
|
-
matrix:
|
11
|
-
include:
|
12
|
-
- rvm: 2.1.10
|
13
|
-
- rvm: 2.2.7
|
14
|
-
- rvm: 2.3.4
|
15
|
-
- rvm: 2.4.1
|
16
|
-
- rvm: jruby-9.1.14.0
|
17
|
-
jdk: oraclejdk8
|
18
|
-
- rvm: 2.2.7
|
19
|
-
install: true # This skips 'bundle install'
|
20
|
-
script: gem build rainbow && gem install *.gem
|
21
|
-
|
22
|
-
env:
|
23
|
-
global:
|
24
|
-
- JRUBY_OPTS=--debug
|
data/Gemfile
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gemspec
|
4
|
-
|
5
|
-
gem 'rake'
|
6
|
-
|
7
|
-
group :test do
|
8
|
-
gem 'coveralls', require: false
|
9
|
-
gem 'rspec'
|
10
|
-
end
|
11
|
-
|
12
|
-
group :development do
|
13
|
-
gem 'mutant-rspec'
|
14
|
-
end
|
15
|
-
|
16
|
-
group :test, :development do
|
17
|
-
gem 'rubocop', '~> 0.51.0'
|
18
|
-
end
|
19
|
-
|
20
|
-
group :guard do
|
21
|
-
gem 'guard'
|
22
|
-
gem 'guard-rspec'
|
23
|
-
end
|
24
|
-
|
25
|
-
platform :rbx do
|
26
|
-
gem 'json'
|
27
|
-
gem 'rubysl'
|
28
|
-
end
|
data/Guardfile
DELETED
data/Rakefile
DELETED
data/appveyor.yml
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
---
|
2
|
-
|
3
|
-
version: "{build}"
|
4
|
-
|
5
|
-
install:
|
6
|
-
- set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
|
7
|
-
- bundle config --local path vendor/bundle
|
8
|
-
- bundle install --jobs 3 --retry 3 --without guard development
|
9
|
-
|
10
|
-
build: off
|
11
|
-
|
12
|
-
cache:
|
13
|
-
- vendor/bundle
|
14
|
-
|
15
|
-
init:
|
16
|
-
- git config --global core.autocrlf true
|
17
|
-
|
18
|
-
before_test:
|
19
|
-
- ruby -v
|
20
|
-
- gem -v
|
21
|
-
- bundle -v
|
22
|
-
|
23
|
-
test_script:
|
24
|
-
- bundle exec rake
|
25
|
-
|
26
|
-
environment:
|
27
|
-
matrix:
|
28
|
-
- RUBY_VERSION: 21
|
29
|
-
- RUBY_VERSION: 21-x64
|
30
|
-
- RUBY_VERSION: 22
|
31
|
-
- RUBY_VERSION: 22-x64
|
32
|
-
- RUBY_VERSION: 23
|
33
|
-
- RUBY_VERSION: 23-x64
|
34
|
-
|
35
|
-
matrix:
|
36
|
-
fast_finish: true
|
37
|
-
|
38
|
-
branches:
|
39
|
-
only:
|
40
|
-
- master
|
data/rainbow.gemspec
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
lib = File.expand_path('../lib', __FILE__)
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require 'rainbow/version'
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = "rainbow"
|
7
|
-
spec.version = Rainbow::VERSION
|
8
|
-
spec.authors = ["Marcin Kulik", "Olle Jonsson"]
|
9
|
-
spec.email = ["m@ku1ik.com"]
|
10
|
-
spec.description = 'Colorize printed text on ANSI terminals'
|
11
|
-
spec.summary = 'Colorize printed text on ANSI terminals'
|
12
|
-
spec.homepage = "https://github.com/sickill/rainbow"
|
13
|
-
spec.license = "MIT"
|
14
|
-
spec.required_ruby_version = '>= 2.1.0'
|
15
|
-
|
16
|
-
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
|
21
|
-
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'rainbow'
|
3
|
-
|
4
|
-
RSpec.describe 'Custom Rainbow instance' do
|
5
|
-
it 'inherits enabled state from the global instance' do
|
6
|
-
Rainbow.enabled = :yep
|
7
|
-
expect(Rainbow.new.enabled).to eq(:yep)
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'tracks its own state separately from the global instance' do
|
11
|
-
Rainbow.enabled = :yep
|
12
|
-
rainbow = Rainbow.new
|
13
|
-
expect(Rainbow.new.enabled).to eq(:yep)
|
14
|
-
|
15
|
-
rainbow.enabled = :nope
|
16
|
-
expect(Rainbow.enabled).to eq(:yep)
|
17
|
-
expect(rainbow.enabled).to eq(:nope)
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'wraps string with escape codes when enabled' do
|
21
|
-
rainbow = Rainbow.new
|
22
|
-
rainbow.enabled = true
|
23
|
-
|
24
|
-
expect(rainbow.wrap('hello').green).to eq("\e[32mhello\e[0m")
|
25
|
-
end
|
26
|
-
|
27
|
-
it "doesn't wrap string with any escape code when disabled" do
|
28
|
-
rainbow = Rainbow.new
|
29
|
-
rainbow.enabled = false
|
30
|
-
|
31
|
-
expect(rainbow.wrap('hello').green).to eq('hello')
|
32
|
-
end
|
33
|
-
end
|