rainbow 3.0.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 +10 -2
- data/README.markdown +3 -0
- metadata +16 -55
- 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/lib/rainbow/color.rb +0 -143
- data/lib/rainbow/ext/string.rb +0 -54
- data/lib/rainbow/global.rb +0 -23
- data/lib/rainbow/null_presenter.rb +0 -93
- data/lib/rainbow/presenter.rb +0 -135
- data/lib/rainbow/refinement.rb +0 -12
- data/lib/rainbow/string_utils.rb +0 -21
- data/lib/rainbow/version.rb +0 -3
- data/lib/rainbow/wrapper.rb +0 -20
- data/lib/rainbow/x11_color_names.rb +0 -151
- data/lib/rainbow.rb +0 -11
- 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
@@ -1,94 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'rainbow/string_utils'
|
3
|
-
|
4
|
-
module Rainbow
|
5
|
-
RSpec.describe StringUtils do
|
6
|
-
describe '.wrap_with_sgr' do
|
7
|
-
subject { described_class.wrap_with_sgr(string, codes) }
|
8
|
-
|
9
|
-
let(:string) { 'hello' }
|
10
|
-
let(:codes) { [1] }
|
11
|
-
|
12
|
-
it "doesn't mutate original string" do
|
13
|
-
string.freeze
|
14
|
-
expect(subject).to eq("\e[1mhello\e[0m")
|
15
|
-
expect(string).to eq('hello')
|
16
|
-
end
|
17
|
-
|
18
|
-
context "when subclass of String class given" do
|
19
|
-
class Stringgg < ::String; end
|
20
|
-
|
21
|
-
let(:string) { Stringgg.new('hello') }
|
22
|
-
|
23
|
-
it { should eq("\e[1mhello\e[0m") }
|
24
|
-
end
|
25
|
-
|
26
|
-
context "when no codes given" do
|
27
|
-
let(:codes) { [] }
|
28
|
-
|
29
|
-
it "doesn't wrap the given string with any sgr sequence" do
|
30
|
-
expect(subject).to eq("hello")
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context "when single code given" do
|
35
|
-
let(:codes) { [1] }
|
36
|
-
|
37
|
-
it "wraps the given string with sgr sequence for given codes" do
|
38
|
-
expect(subject).to eq("\e[1mhello\e[0m")
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
context "when multiple codes given" do
|
43
|
-
let(:codes) { [1, 2] }
|
44
|
-
|
45
|
-
it "wraps the given string with sgr sequence for given codes" do
|
46
|
-
expect(subject).to eq("\e[1;2mhello\e[0m")
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context "when wrapping an already wrapped string" do
|
51
|
-
let(:string) { "\e[1;2mhello\e[0m" }
|
52
|
-
let(:codes) { [3, 4] }
|
53
|
-
|
54
|
-
it "wraps the given string with sgr sequence for given codes" do
|
55
|
-
expect(subject).to eq("\e[1;2m\e[3;4mhello\e[0m")
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe '.uncolor' do
|
61
|
-
subject { described_class.uncolor(string) }
|
62
|
-
|
63
|
-
context "when string with ansi color escape is passed" do
|
64
|
-
let(:string) do
|
65
|
-
rainbow = Rainbow.new
|
66
|
-
rainbow.enabled = true
|
67
|
-
rainbow.wrap('hello').
|
68
|
-
foreground(:red).
|
69
|
-
bright.
|
70
|
-
bold.
|
71
|
-
italic.
|
72
|
-
background('#ff8040').
|
73
|
-
underline.
|
74
|
-
color(:blue).
|
75
|
-
blink.
|
76
|
-
inverse.
|
77
|
-
hide
|
78
|
-
end
|
79
|
-
|
80
|
-
it "removes ansi color codes" do
|
81
|
-
expect(subject).to eq 'hello'
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
context "when string with scroll down ansi escape is passed" do
|
86
|
-
let(:string) { "\e[1Thello" }
|
87
|
-
|
88
|
-
it "does not remove ansi scroll down escape" do
|
89
|
-
expect(subject).to eq "\e[1Thello"
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
data/spec/unit/wrapper_spec.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'rainbow/wrapper'
|
3
|
-
|
4
|
-
module Rainbow
|
5
|
-
RSpec.describe Wrapper do
|
6
|
-
let(:wrapper) { described_class.new(enabled) }
|
7
|
-
|
8
|
-
it "is enabled by default" do
|
9
|
-
expect(described_class.new.enabled).to be(true)
|
10
|
-
end
|
11
|
-
|
12
|
-
describe '#wrap' do
|
13
|
-
subject { wrapper.wrap(object) }
|
14
|
-
|
15
|
-
let(:object) { Object.new }
|
16
|
-
|
17
|
-
context "when wrapping is enabled" do
|
18
|
-
let(:enabled) { true }
|
19
|
-
|
20
|
-
it { should eq(object.to_s) }
|
21
|
-
it { should be_kind_of(Rainbow::Presenter) }
|
22
|
-
end
|
23
|
-
|
24
|
-
context "when wrapping is disabled" do
|
25
|
-
let(:enabled) { false }
|
26
|
-
|
27
|
-
it { should eq(object.to_s) }
|
28
|
-
it { should be_kind_of(Rainbow::NullPresenter) }
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|