pastel 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +57 -13
  3. data/README.md +36 -29
  4. data/lib/pastel.rb +17 -19
  5. data/lib/pastel/alias_importer.rb +9 -7
  6. data/lib/pastel/ansi.rb +2 -2
  7. data/lib/pastel/color.rb +63 -23
  8. data/lib/pastel/color_parser.rb +24 -18
  9. data/lib/pastel/color_resolver.rb +3 -1
  10. data/lib/pastel/decorator_chain.rb +47 -7
  11. data/lib/pastel/delegator.rb +57 -26
  12. data/lib/pastel/detached.rb +41 -5
  13. data/lib/pastel/version.rb +2 -2
  14. metadata +27 -97
  15. data/.gitignore +0 -22
  16. data/.rspec +0 -3
  17. data/.travis.yml +0 -26
  18. data/Gemfile +0 -16
  19. data/Rakefile +0 -8
  20. data/appveyor.yml +0 -23
  21. data/assets/pastel_logo.png +0 -0
  22. data/assets/screenshot.png +0 -0
  23. data/benchmarks/nesting_speed.rb +0 -41
  24. data/benchmarks/speed.rb +0 -45
  25. data/examples/palette.rb +0 -14
  26. data/pastel.gemspec +0 -26
  27. data/spec/spec_helper.rb +0 -45
  28. data/spec/unit/alias_color_spec.rb +0 -24
  29. data/spec/unit/alias_importer_spec.rb +0 -29
  30. data/spec/unit/color/alias_color_spec.rb +0 -40
  31. data/spec/unit/color/code_spec.rb +0 -24
  32. data/spec/unit/color/colored_spec.rb +0 -15
  33. data/spec/unit/color/decorate_spec.rb +0 -79
  34. data/spec/unit/color/equal_spec.rb +0 -22
  35. data/spec/unit/color/lookup_spec.rb +0 -17
  36. data/spec/unit/color/new_spec.rb +0 -10
  37. data/spec/unit/color/strip_spec.rb +0 -56
  38. data/spec/unit/color/styles_spec.rb +0 -10
  39. data/spec/unit/color/valid_spec.rb +0 -19
  40. data/spec/unit/color_parser_spec.rb +0 -67
  41. data/spec/unit/decorate_dsl_spec.rb +0 -98
  42. data/spec/unit/decorator_chain_spec.rb +0 -47
  43. data/spec/unit/delegator_spec.rb +0 -38
  44. data/spec/unit/detach_spec.rb +0 -48
  45. data/spec/unit/new_spec.rb +0 -63
  46. data/spec/unit/respond_to_spec.rb +0 -17
  47. data/spec/unit/undecorate_spec.rb +0 -12
  48. data/tasks/console.rake +0 -11
  49. data/tasks/coverage.rake +0 -11
  50. data/tasks/spec.rake +0 -29
@@ -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
@@ -1,11 +0,0 @@
1
- # encoding: utf-8
2
-
3
- desc 'Load gem inside irb console'
4
- task :console do
5
- require 'irb'
6
- require 'irb/completion'
7
- require File.join(__FILE__, '../../lib/pastel')
8
- ARGV.clear
9
- IRB.start
10
- end
11
- task c: :console
@@ -1,11 +0,0 @@
1
- # encoding: utf-8
2
-
3
- desc 'Measure code coverage'
4
- task :coverage do
5
- begin
6
- original, ENV['COVERAGE'] = ENV['COVERAGE'], 'true'
7
- Rake::Task['spec'].invoke
8
- ensure
9
- ENV['COVERAGE'] = original
10
- end
11
- end
@@ -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