pastel 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +57 -13
- data/README.md +36 -29
- data/lib/pastel.rb +17 -19
- data/lib/pastel/alias_importer.rb +9 -7
- data/lib/pastel/ansi.rb +2 -2
- data/lib/pastel/color.rb +63 -23
- data/lib/pastel/color_parser.rb +24 -18
- data/lib/pastel/color_resolver.rb +3 -1
- data/lib/pastel/decorator_chain.rb +47 -7
- data/lib/pastel/delegator.rb +57 -26
- data/lib/pastel/detached.rb +41 -5
- data/lib/pastel/version.rb +2 -2
- metadata +27 -97
- data/.gitignore +0 -22
- data/.rspec +0 -3
- data/.travis.yml +0 -26
- data/Gemfile +0 -16
- data/Rakefile +0 -8
- data/appveyor.yml +0 -23
- data/assets/pastel_logo.png +0 -0
- data/assets/screenshot.png +0 -0
- data/benchmarks/nesting_speed.rb +0 -41
- data/benchmarks/speed.rb +0 -45
- data/examples/palette.rb +0 -14
- data/pastel.gemspec +0 -26
- data/spec/spec_helper.rb +0 -45
- data/spec/unit/alias_color_spec.rb +0 -24
- data/spec/unit/alias_importer_spec.rb +0 -29
- data/spec/unit/color/alias_color_spec.rb +0 -40
- data/spec/unit/color/code_spec.rb +0 -24
- data/spec/unit/color/colored_spec.rb +0 -15
- data/spec/unit/color/decorate_spec.rb +0 -79
- data/spec/unit/color/equal_spec.rb +0 -22
- data/spec/unit/color/lookup_spec.rb +0 -17
- data/spec/unit/color/new_spec.rb +0 -10
- data/spec/unit/color/strip_spec.rb +0 -56
- data/spec/unit/color/styles_spec.rb +0 -10
- data/spec/unit/color/valid_spec.rb +0 -19
- data/spec/unit/color_parser_spec.rb +0 -67
- data/spec/unit/decorate_dsl_spec.rb +0 -98
- data/spec/unit/decorator_chain_spec.rb +0 -47
- data/spec/unit/delegator_spec.rb +0 -38
- data/spec/unit/detach_spec.rb +0 -48
- data/spec/unit/new_spec.rb +0 -63
- data/spec/unit/respond_to_spec.rb +0 -17
- data/spec/unit/undecorate_spec.rb +0 -12
- data/tasks/console.rake +0 -11
- data/tasks/coverage.rake +0 -11
- data/tasks/spec.rake +0 -29
data/spec/unit/new_spec.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
RSpec.describe Pastel, '#new' do
|
4
|
-
|
5
|
-
subject(:pastel) { described_class.new(enabled: true) }
|
6
|
-
|
7
|
-
it { is_expected.to respond_to(:lookup) }
|
8
|
-
|
9
|
-
it { is_expected.to respond_to(:decorate) }
|
10
|
-
|
11
|
-
it { is_expected.to respond_to(:undecorate) }
|
12
|
-
|
13
|
-
it { is_expected.to respond_to(:strip) }
|
14
|
-
|
15
|
-
describe '#valid?' do
|
16
|
-
it "when valid returns true" do
|
17
|
-
expect(pastel.valid?(:red)).to eq(true)
|
18
|
-
end
|
19
|
-
|
20
|
-
it "returns false when invalid" do
|
21
|
-
expect(pastel.valid?(:unknown)).to eq(false)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe '#colored?' do
|
26
|
-
it "checks if string is colored" do
|
27
|
-
expect(pastel.colored?("\e[31mfoo\e[0m")).to eq(true)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe 'options passed in' do
|
32
|
-
it 'defaults enabled to color detection' do
|
33
|
-
allow(TTY::Color).to receive(:color?).and_return(true)
|
34
|
-
allow(TTY::Color).to receive(:windows?).and_return(false)
|
35
|
-
|
36
|
-
pastel = described_class.new
|
37
|
-
|
38
|
-
expect(pastel.enabled?).to eq(true)
|
39
|
-
expect(TTY::Color).to have_received(:color?)
|
40
|
-
end
|
41
|
-
|
42
|
-
it "defaults to enabled on Windows" do
|
43
|
-
allow(TTY::Color).to receive(:color?).and_return(false)
|
44
|
-
allow(TTY::Color).to receive(:windows?).and_return(true)
|
45
|
-
|
46
|
-
pastel = described_class.new
|
47
|
-
|
48
|
-
expect(pastel.enabled?).to eq(true)
|
49
|
-
expect(TTY::Color).to_not have_received(:color?)
|
50
|
-
end
|
51
|
-
|
52
|
-
it "sets enabled option" do
|
53
|
-
pastel = described_class.new(enabled: false)
|
54
|
-
expect(pastel.enabled?).to eq(false)
|
55
|
-
expect(pastel.red('Unicorn', pastel.green('!'))).to eq('Unicorn!')
|
56
|
-
end
|
57
|
-
|
58
|
-
it "sets eachline option" do
|
59
|
-
pastel = described_class.new(enabled: true, eachline: "\n")
|
60
|
-
expect(pastel.red("foo\nbar")).to eq("\e[31mfoo\e[0m\n\e[31mbar\e[0m")
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
RSpec.describe Pastel, '.respond_to?' do
|
4
|
-
subject(:pastel) { described_class.new(enabled: true) }
|
5
|
-
|
6
|
-
it "responds correctly to color method" do
|
7
|
-
expect(pastel.respond_to?(:decorate)).to eq(true)
|
8
|
-
end
|
9
|
-
|
10
|
-
it "responds correctly to color property" do
|
11
|
-
expect(pastel.respond_to?(:red)).to eq(true)
|
12
|
-
end
|
13
|
-
|
14
|
-
it "responds correctly to unkown method" do
|
15
|
-
expect(pastel.respond_to?(:unknown)).to eq(false)
|
16
|
-
end
|
17
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
RSpec.describe Pastel, '#undecorate' do
|
4
|
-
subject(:pastel) { described_class.new(enabled: true) }
|
5
|
-
|
6
|
-
it "undecorates string detecting color escape codes" do
|
7
|
-
string = pastel.red.on_green('foo')
|
8
|
-
expect(pastel.undecorate(string)).to eq([
|
9
|
-
{foreground: :red, background: :on_green, text: 'foo'}
|
10
|
-
])
|
11
|
-
end
|
12
|
-
end
|
data/tasks/console.rake
DELETED
data/tasks/coverage.rake
DELETED
data/tasks/spec.rake
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'rspec/core/rake_task'
|
5
|
-
|
6
|
-
desc 'Run all specs'
|
7
|
-
RSpec::Core::RakeTask.new(:spec) do |task|
|
8
|
-
task.pattern = 'spec/{unit,integration}{,/*/**}/*_spec.rb'
|
9
|
-
end
|
10
|
-
|
11
|
-
namespace :spec do
|
12
|
-
desc 'Run unit specs'
|
13
|
-
RSpec::Core::RakeTask.new(:unit) do |task|
|
14
|
-
task.pattern = 'spec/unit{,/*/**}/*_spec.rb'
|
15
|
-
end
|
16
|
-
|
17
|
-
desc 'Run integration specs'
|
18
|
-
RSpec::Core::RakeTask.new(:integration) do |task|
|
19
|
-
task.pattern = 'spec/integration{,/*/**}/*_spec.rb'
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
rescue LoadError
|
24
|
-
%w[spec spec:unit spec:integration].each do |name|
|
25
|
-
task name do
|
26
|
-
$stderr.puts "In order to run #{name}, do `gem install rspec`"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|