rainbow 1.99.0 → 2.0.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 +4 -4
- data/.rubocop.yml +14 -0
- data/.travis.yml +0 -1
- data/Changelog.md +67 -0
- data/Gemfile +3 -3
- data/Guardfile +1 -1
- data/README.markdown +92 -35
- data/lib/rainbow/color.rb +28 -22
- data/lib/rainbow/ext/string.rb +52 -0
- data/lib/rainbow/global.rb +21 -0
- data/lib/rainbow/legacy.rb +2 -1
- data/lib/rainbow/null_presenter.rb +30 -0
- data/lib/rainbow/presenter.rb +113 -0
- data/lib/rainbow/version.rb +1 -1
- data/lib/rainbow/wrapper.rb +12 -66
- data/lib/rainbow.rb +17 -19
- data/rainbow.gemspec +9 -9
- data/spec/integration/instance_spec.rb +35 -0
- data/spec/integration/rainbow_spec.rb +13 -6
- data/spec/integration/string_spec.rb +27 -1
- data/spec/spec_helper.rb +1 -5
- data/spec/support/presenter_shared_examples.rb +9 -0
- data/spec/unit/null_presenter_spec.rb +93 -0
- data/spec/unit/presenter_spec.rb +168 -0
- data/spec/unit/wrapper_spec.rb +11 -132
- metadata +17 -6
- data/Changelog +0 -3
- data/lib/rainbow/core.rb +0 -16
- data/lib/rainbow/string.rb +0 -50
data/spec/unit/wrapper_spec.rb
CHANGED
|
@@ -4,144 +4,23 @@ require 'rainbow/wrapper'
|
|
|
4
4
|
module Rainbow
|
|
5
5
|
describe Wrapper do
|
|
6
6
|
|
|
7
|
-
let(:wrapper) { described_class.new(
|
|
7
|
+
let(:wrapper) { described_class.new(enabled) }
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
expect(subject).to eq('[hello]')
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
it "returns an instance of Rainbow::Wrapper" do
|
|
15
|
-
expect(subject).to be_kind_of(Rainbow::Wrapper)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
context "when Rainbow is disabled" do
|
|
19
|
-
before do
|
|
20
|
-
allow(Rainbow).to receive(:enabled) { false }
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it "doesn't wrap the text" do
|
|
24
|
-
expect(subject).to eq('hello')
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
it "returns an instance of Rainbow::Wrapper" do
|
|
28
|
-
expect(subject).to be_kind_of(Rainbow::Wrapper)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
before do
|
|
34
|
-
allow(StringUtils).to receive(:wrap_with_sgr) { '[hello]' }
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
describe '#foreground' do
|
|
38
|
-
subject { wrapper.foreground(:arg1, 'arg2') }
|
|
39
|
-
|
|
40
|
-
let(:color) { double('color', :codes => [1, 2]) }
|
|
41
|
-
|
|
42
|
-
before do
|
|
43
|
-
allow(Color).to receive(:build).with(:foreground, [:arg1, 'arg2']) { color }
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
it_behaves_like "wrapper method"
|
|
47
|
-
|
|
48
|
-
it 'wraps with color codes' do
|
|
49
|
-
subject
|
|
50
|
-
expect(StringUtils).to have_received(:wrap_with_sgr).with('hello', [1, 2])
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
describe '#background' do
|
|
55
|
-
subject { wrapper.background(:arg1, 'arg2') }
|
|
56
|
-
|
|
57
|
-
let(:color) { double('color', :codes => [1, 2]) }
|
|
58
|
-
|
|
59
|
-
before do
|
|
60
|
-
allow(Color).to receive(:build).with(:background, [:arg1, 'arg2']) { color }
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
it_behaves_like "wrapper method"
|
|
64
|
-
|
|
65
|
-
it 'wraps with color codes' do
|
|
66
|
-
subject
|
|
67
|
-
expect(StringUtils).to have_received(:wrap_with_sgr).with('hello', [1, 2])
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
describe '#reset' do
|
|
72
|
-
subject { wrapper.reset }
|
|
9
|
+
describe '#wrap' do
|
|
10
|
+
subject { wrapper.wrap('hello') }
|
|
73
11
|
|
|
74
|
-
|
|
12
|
+
context "when wrapping is enabled" do
|
|
13
|
+
let(:enabled) { true }
|
|
75
14
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
expect(StringUtils).to have_received(:wrap_with_sgr).with('hello', [0])
|
|
15
|
+
it { should eq('hello') }
|
|
16
|
+
it { should be_kind_of(Rainbow::Presenter) }
|
|
79
17
|
end
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
describe '#bright' do
|
|
83
|
-
subject { wrapper.bright }
|
|
84
|
-
|
|
85
|
-
it_behaves_like "wrapper method"
|
|
86
|
-
|
|
87
|
-
it 'wraps with 1 code' do
|
|
88
|
-
subject
|
|
89
|
-
expect(StringUtils).to have_received(:wrap_with_sgr).with('hello', [1])
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
describe '#italic' do
|
|
94
|
-
subject { wrapper.italic }
|
|
95
|
-
|
|
96
|
-
it_behaves_like "wrapper method"
|
|
97
|
-
|
|
98
|
-
it 'wraps with 3 code' do
|
|
99
|
-
subject
|
|
100
|
-
expect(StringUtils).to have_received(:wrap_with_sgr).with('hello', [3])
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
describe '#underline' do
|
|
105
|
-
subject { wrapper.underline }
|
|
106
|
-
|
|
107
|
-
it_behaves_like "wrapper method"
|
|
108
|
-
|
|
109
|
-
it 'wraps with 4 code' do
|
|
110
|
-
subject
|
|
111
|
-
expect(StringUtils).to have_received(:wrap_with_sgr).with('hello', [4])
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
describe '#blink' do
|
|
116
|
-
subject { wrapper.blink }
|
|
117
|
-
|
|
118
|
-
it_behaves_like "wrapper method"
|
|
119
|
-
|
|
120
|
-
it 'wraps with 5 code' do
|
|
121
|
-
subject
|
|
122
|
-
expect(StringUtils).to have_received(:wrap_with_sgr).with('hello', [5])
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
describe '#inverse' do
|
|
127
|
-
subject { wrapper.inverse }
|
|
128
|
-
|
|
129
|
-
it_behaves_like "wrapper method"
|
|
130
|
-
|
|
131
|
-
it 'wraps with 7 code' do
|
|
132
|
-
subject
|
|
133
|
-
expect(StringUtils).to have_received(:wrap_with_sgr).with('hello', [7])
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
describe '#hide' do
|
|
138
|
-
subject { wrapper.hide }
|
|
139
18
|
|
|
140
|
-
|
|
19
|
+
context "when wrapping is disabled" do
|
|
20
|
+
let(:enabled) { false }
|
|
141
21
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
expect(StringUtils).to have_received(:wrap_with_sgr).with('hello', [8])
|
|
22
|
+
it { should eq('hello') }
|
|
23
|
+
it { should be_kind_of(Rainbow::NullPresenter) }
|
|
145
24
|
end
|
|
146
25
|
end
|
|
147
26
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rainbow
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Marcin Kulik
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2014-01-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -60,8 +60,9 @@ extensions: []
|
|
|
60
60
|
extra_rdoc_files: []
|
|
61
61
|
files:
|
|
62
62
|
- .gitignore
|
|
63
|
+
- .rubocop.yml
|
|
63
64
|
- .travis.yml
|
|
64
|
-
- Changelog
|
|
65
|
+
- Changelog.md
|
|
65
66
|
- Gemfile
|
|
66
67
|
- Guardfile
|
|
67
68
|
- LICENSE
|
|
@@ -69,18 +70,24 @@ files:
|
|
|
69
70
|
- Rakefile
|
|
70
71
|
- lib/rainbow.rb
|
|
71
72
|
- lib/rainbow/color.rb
|
|
72
|
-
- lib/rainbow/
|
|
73
|
+
- lib/rainbow/ext/string.rb
|
|
74
|
+
- lib/rainbow/global.rb
|
|
73
75
|
- lib/rainbow/legacy.rb
|
|
74
|
-
- lib/rainbow/
|
|
76
|
+
- lib/rainbow/null_presenter.rb
|
|
77
|
+
- lib/rainbow/presenter.rb
|
|
75
78
|
- lib/rainbow/string_utils.rb
|
|
76
79
|
- lib/rainbow/version.rb
|
|
77
80
|
- lib/rainbow/wrapper.rb
|
|
78
81
|
- rainbow.gemspec
|
|
82
|
+
- spec/integration/instance_spec.rb
|
|
79
83
|
- spec/integration/rainbow_spec.rb
|
|
80
84
|
- spec/integration/string_spec.rb
|
|
81
85
|
- spec/spec_helper.rb
|
|
86
|
+
- spec/support/presenter_shared_examples.rb
|
|
82
87
|
- spec/unit/color_spec.rb
|
|
83
88
|
- spec/unit/namespace_spec.rb
|
|
89
|
+
- spec/unit/null_presenter_spec.rb
|
|
90
|
+
- spec/unit/presenter_spec.rb
|
|
84
91
|
- spec/unit/string_utils_spec.rb
|
|
85
92
|
- spec/unit/wrapper_spec.rb
|
|
86
93
|
homepage: https://github.com/sickill/rainbow
|
|
@@ -95,7 +102,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
95
102
|
requirements:
|
|
96
103
|
- - '>='
|
|
97
104
|
- !ruby/object:Gem::Version
|
|
98
|
-
version:
|
|
105
|
+
version: 1.9.2
|
|
99
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
107
|
requirements:
|
|
101
108
|
- - '>='
|
|
@@ -108,10 +115,14 @@ signing_key:
|
|
|
108
115
|
specification_version: 4
|
|
109
116
|
summary: Colorize printed text on ANSI terminals
|
|
110
117
|
test_files:
|
|
118
|
+
- spec/integration/instance_spec.rb
|
|
111
119
|
- spec/integration/rainbow_spec.rb
|
|
112
120
|
- spec/integration/string_spec.rb
|
|
113
121
|
- spec/spec_helper.rb
|
|
122
|
+
- spec/support/presenter_shared_examples.rb
|
|
114
123
|
- spec/unit/color_spec.rb
|
|
115
124
|
- spec/unit/namespace_spec.rb
|
|
125
|
+
- spec/unit/null_presenter_spec.rb
|
|
126
|
+
- spec/unit/presenter_spec.rb
|
|
116
127
|
- spec/unit/string_utils_spec.rb
|
|
117
128
|
- spec/unit/wrapper_spec.rb
|
data/Changelog
DELETED
data/lib/rainbow/core.rb
DELETED
data/lib/rainbow/string.rb
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
require 'rainbow'
|
|
2
|
-
|
|
3
|
-
module Rainbow
|
|
4
|
-
module String
|
|
5
|
-
module InstanceMethods
|
|
6
|
-
|
|
7
|
-
def foreground(*color)
|
|
8
|
-
Rainbow(self).foreground(*color)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
alias_method :color, :foreground
|
|
12
|
-
alias_method :colour, :foreground
|
|
13
|
-
|
|
14
|
-
def background(*color)
|
|
15
|
-
Rainbow(self).background(*color)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def reset
|
|
19
|
-
Rainbow(self).reset
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def bright
|
|
23
|
-
Rainbow(self).bright
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def italic
|
|
27
|
-
Rainbow(self).italic
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def underline
|
|
31
|
-
Rainbow(self).underline
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def blink
|
|
35
|
-
Rainbow(self).blink
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def inverse
|
|
39
|
-
Rainbow(self).inverse
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def hide
|
|
43
|
-
Rainbow(self).hide
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
::String.send(:include, Rainbow::String::InstanceMethods)
|