colored2 3.1.2 → 4.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 +5 -5
- data/README.md +9 -6
- data/Rakefile +6 -2
- data/lib/colored2/ascii_decorator.rb +17 -4
- data/lib/colored2/codes.rb +23 -21
- data/lib/colored2/numbers.rb +4 -2
- data/lib/colored2/object.rb +2 -0
- data/lib/colored2/strings.rb +2 -0
- data/lib/colored2/version.rb +3 -1
- data/lib/colored2.rb +18 -15
- metadata +13 -64
- data/spec/colored2/numbers_spec.rb +0 -26
- data/spec/colored2/object_spec.rb +0 -24
- data/spec/colored2/strings_spec.rb +0 -77
- data/spec/colored2_spec.rb +0 -23
- data/spec/spec_helper.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 931fcb1dc0aebdc4cee8c0b71849879b22878076547172885d4a15fc6bd19e80
|
4
|
+
data.tar.gz: 07263f510c64006915085ba83c1c4ca84e16208c93ebe9696a4802eb6f4afb59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7434349bb14787804acb8cf8692e522f0accf8d751ef45672bce10171ad4bce61318df04676af58dbf64a5fbe399e89f1b741e7ba6b0c5c8b608db7a42085874
|
7
|
+
data.tar.gz: 3a8a6bf7fe16badb197728f645c8e16c5c48f7f933e3c2e5d68a2b1dbdc24c6706638a8d39ae1fc38dec68a4f1348c2db673c6d21a80b5f314355b95a6601ff5
|
data/README.md
CHANGED
@@ -1,18 +1,21 @@
|
|
1
|
+
|
2
|
+
[](https://github.com/kigster/colored2/actions/workflows/ruby-ci.yml)
|
3
|
+
[](https://github.com/kigster/colored2/actions/workflows/rubocop-ci.yml)
|
4
|
+
|
1
5
|
[](https://badge.fury.io/rb/colored2)
|
2
|
-
[](https://rubygems.org/gems/colored2)
|
3
6
|
[](https://gitter.im/colored2)
|
4
7
|
|
5
|
-
[](https://travis-ci.org/kigster/colored2)
|
6
|
-
[](https://codeclimate.com/github/kigster/colored2/coverage)
|
7
|
-
[](https://codeclimate.com/github/kigster/colored2)
|
8
|
-
[](https://codeclimate.com/github/kigster/colored2)
|
9
|
-
|
10
8
|
## Colored2
|
11
9
|
|
12
10
|
This is an actively maintained fork of Chris (defunkt) Wanstrath's gem [colored](https://github.com/defunkt/colored), which appears to be no longer supported.
|
13
11
|
|
14
12
|
This fork comes with a slightly spruced up syntax, some additional features, and a test suite written in [RSpec](http://rspec.info/).
|
15
13
|
|
14
|
+
## Please Consider Donating
|
15
|
+
|
16
|
+
<a href="https://liberapay.com/kigster/donate"><img alt="Donate using Liberapay" src="https://liberapay.com/assets/widgets/donate.svg" height="30"></a>
|
17
|
+
<a href="https://liberapay.com/kigster/donate"><img alt="Donate using Liberapay" src="https://img.shields.io/liberapay/goal/kigster.svg" height="30"></a>
|
18
|
+
|
16
19
|
## Usage
|
17
20
|
|
18
21
|
In addition to the simple syntax of the original gem, which affected only the string to the left of the method call, the new "bang" syntax affects a string to the right. If the block or a method argument is provided, the contents is wrapped in the color, and the color is then reset back.
|
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
|
1
3
|
require 'bundler'
|
2
4
|
require 'bundler/gem_tasks'
|
3
5
|
require 'rake/clean'
|
@@ -7,7 +9,9 @@ CLEAN.include %w(pkg coverage *.gem)
|
|
7
9
|
begin
|
8
10
|
require 'rspec/core/rake_task'
|
9
11
|
RSpec::Core::RakeTask.new(:spec)
|
10
|
-
rescue LoadError
|
12
|
+
rescue LoadError => e
|
13
|
+
warn "Error loading task: #{e.message}"
|
14
|
+
exit 1
|
11
15
|
end
|
12
16
|
|
13
|
-
task :
|
17
|
+
task default: [:spec]
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
|
1
3
|
require 'colored2/codes'
|
2
4
|
require 'forwardable'
|
3
5
|
|
@@ -5,15 +7,19 @@ module Colored2
|
|
5
7
|
def self.enable!
|
6
8
|
Colored2::AsciiDecorator.enable!
|
7
9
|
end
|
10
|
+
|
8
11
|
def self.disable!
|
9
12
|
Colored2::AsciiDecorator.disable!
|
10
13
|
end
|
14
|
+
|
11
15
|
def self.background_next!
|
12
16
|
Colored2::AsciiDecorator.background_next!
|
13
17
|
end
|
18
|
+
|
14
19
|
def self.foreground_next!
|
15
20
|
Colored2::AsciiDecorator.foreground_next!
|
16
21
|
end
|
22
|
+
|
17
23
|
def self.background_next?
|
18
24
|
Colored2::AsciiDecorator.background_next?
|
19
25
|
end
|
@@ -23,23 +29,29 @@ module Colored2
|
|
23
29
|
@__colors_disabled = false
|
24
30
|
class << self
|
25
31
|
attr_accessor :__background_next, :__colors_disabled
|
32
|
+
|
26
33
|
def enable!
|
27
34
|
self.__colors_disabled = false
|
28
35
|
end
|
36
|
+
|
29
37
|
def enabled?
|
30
|
-
!
|
38
|
+
!__colors_disabled
|
31
39
|
end
|
40
|
+
|
32
41
|
def disable!
|
33
42
|
self.__colors_disabled = true
|
34
43
|
end
|
44
|
+
|
35
45
|
def background_next!
|
36
46
|
self.__background_next = true
|
37
47
|
end
|
48
|
+
|
38
49
|
def foreground_next!
|
39
50
|
self.__background_next = false
|
40
51
|
end
|
52
|
+
|
41
53
|
def background_next?
|
42
|
-
|
54
|
+
__background_next
|
43
55
|
end
|
44
56
|
end
|
45
57
|
|
@@ -56,7 +68,8 @@ module Colored2
|
|
56
68
|
# options[:start] = :color
|
57
69
|
# options[:end] = :color | :no_color
|
58
70
|
def decorate(options = {})
|
59
|
-
return string if !self.class.enabled? || string.
|
71
|
+
return string if !self.class.enabled? || string.empty?
|
72
|
+
|
60
73
|
escape_sequence = [
|
61
74
|
Colored2::TextColor.new(options[:foreground]),
|
62
75
|
Colored2::BackgroundColor.new(options[:background]),
|
@@ -74,7 +87,7 @@ module Colored2
|
|
74
87
|
end
|
75
88
|
|
76
89
|
def un_decorate
|
77
|
-
string.gsub(
|
90
|
+
string.gsub(/\e\[\d+(;\d+)*m/, '')
|
78
91
|
end
|
79
92
|
|
80
93
|
private
|
data/lib/colored2/codes.rb
CHANGED
@@ -1,34 +1,37 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: false
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
3
|
+
module Colored2
|
4
|
+
COLORS = {
|
5
|
+
black: 30,
|
6
|
+
red: 31,
|
7
|
+
green: 32,
|
8
|
+
yellow: 33,
|
9
|
+
blue: 34,
|
10
|
+
magenta: 35,
|
11
|
+
cyan: 36,
|
12
|
+
white: 37
|
13
|
+
}.freeze
|
13
14
|
|
14
15
|
EFFECTS = {
|
15
|
-
no_color:
|
16
|
-
bold:
|
17
|
-
dark:
|
18
|
-
italic:
|
16
|
+
no_color: 0,
|
17
|
+
bold: 1,
|
18
|
+
dark: 2,
|
19
|
+
italic: 3,
|
19
20
|
underlined: 4,
|
20
|
-
reversed:
|
21
|
-
plain:
|
22
|
-
normal:
|
23
|
-
}
|
21
|
+
reversed: 7,
|
22
|
+
plain: 21, # non-bold
|
23
|
+
normal: 22
|
24
|
+
}.freeze
|
24
25
|
|
25
26
|
class Code
|
26
27
|
attr_accessor :name, :escape
|
28
|
+
|
27
29
|
def initialize(name)
|
28
30
|
@name = name
|
29
31
|
return if name.nil?
|
32
|
+
|
30
33
|
@escape = codes[name.to_sym]
|
31
|
-
raise ArgumentError
|
34
|
+
raise ArgumentError, "No color or effect named #{name} exists for #{self.class}." if @escape.nil?
|
32
35
|
end
|
33
36
|
|
34
37
|
def value(shift = nil)
|
@@ -59,5 +62,4 @@ module Colored2
|
|
59
62
|
super 10
|
60
63
|
end
|
61
64
|
end
|
62
|
-
|
63
65
|
end
|
data/lib/colored2/numbers.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
|
1
3
|
require 'colored2' unless defined?(Colored2) && Colored2.respond_to?(:decorate)
|
2
4
|
|
3
5
|
module Colored2
|
4
6
|
def self.integer_class
|
5
|
-
major, minor = RUBY_VERSION.split(
|
6
|
-
major >= 2 && minor >= 4 ? Integer :
|
7
|
+
major, minor = RUBY_VERSION.split(".").map(&:to_i)
|
8
|
+
major >= 2 && minor >= 4 ? Integer : Numeric
|
7
9
|
end
|
8
10
|
end
|
9
11
|
|
data/lib/colored2/object.rb
CHANGED
data/lib/colored2/strings.rb
CHANGED
data/lib/colored2/version.rb
CHANGED
data/lib/colored2.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
|
1
3
|
require 'colored2/codes'
|
2
4
|
require 'colored2/ascii_decorator'
|
3
5
|
|
@@ -8,7 +10,6 @@ module Colored2
|
|
8
10
|
|
9
11
|
def self.included(from_class)
|
10
12
|
from_class.class_eval do
|
11
|
-
|
12
13
|
def surround_with_color(color: nil, effect: nil, color_self: nil, string: nil, &block)
|
13
14
|
color_type = if Colored2.background_next? && effect.nil?
|
14
15
|
Colored2.foreground_next!
|
@@ -17,23 +18,23 @@ module Colored2
|
|
17
18
|
:foreground
|
18
19
|
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
opts = {}
|
22
|
+
opts.merge!(color_type => color) if color
|
23
|
+
opts.merge!(effect:) if effect
|
23
24
|
|
24
|
-
if color_self
|
25
|
+
if color_self
|
25
26
|
opts.merge!( beginning: :on, end: :off)
|
26
27
|
colored = Colored2::AsciiDecorator.new(self).decorate(opts)
|
27
28
|
if string || block
|
28
|
-
arg = "#{string}#{block
|
29
|
-
colored << Colored2::AsciiDecorator.new(arg).decorate(opts) if arg.
|
29
|
+
arg = "#{string}#{block&.call}"
|
30
|
+
colored << Colored2::AsciiDecorator.new(arg).decorate(opts) if !arg.empty?
|
30
31
|
end
|
31
32
|
else
|
32
33
|
opts.merge!( end: :on )
|
33
34
|
colored = Colored2::AsciiDecorator.new(self).decorate(opts)
|
34
35
|
if string || block
|
35
|
-
arg = "#{string}#{block
|
36
|
-
colored << Colored2::AsciiDecorator.new(arg).decorate(opts.merge(end: :off)) if arg.
|
36
|
+
arg = "#{string}#{block&.call}"
|
37
|
+
colored << Colored2::AsciiDecorator.new(arg).decorate(opts.merge(end: :off)) if !arg.empty?
|
37
38
|
end
|
38
39
|
end
|
39
40
|
colored
|
@@ -46,24 +47,25 @@ module Colored2
|
|
46
47
|
end
|
47
48
|
|
48
49
|
from_class.instance_eval do
|
49
|
-
COLORS.
|
50
|
+
COLORS.each_key do |color|
|
50
51
|
define_method(color) do |string = nil, &block|
|
51
|
-
surround_with_color(color
|
52
|
+
surround_with_color(color:, color_self: true, string:, &block)
|
52
53
|
end
|
53
54
|
|
54
55
|
define_method("#{color}!".to_sym) do |string = nil, &block|
|
55
|
-
surround_with_color(color
|
56
|
+
surround_with_color(color:, color_self: false, string:, &block)
|
56
57
|
end
|
57
58
|
end
|
58
59
|
|
59
|
-
EFFECTS.
|
60
|
+
EFFECTS.each_key do |effect|
|
60
61
|
next if effect == 'no_color'
|
62
|
+
|
61
63
|
define_method(effect) do |string = nil, &block|
|
62
|
-
surround_with_color(effect
|
64
|
+
surround_with_color(effect:, color_self: true, string:, &block)
|
63
65
|
end
|
64
66
|
|
65
67
|
define_method("#{effect}!".to_sym) do |string = nil, &block|
|
66
|
-
surround_with_color(effect
|
68
|
+
surround_with_color(effect:, color_self: false, string:, &block)
|
67
69
|
end
|
68
70
|
end
|
69
71
|
|
@@ -72,6 +74,7 @@ module Colored2
|
|
72
74
|
if tmp == self
|
73
75
|
return "\e[2K" << self
|
74
76
|
end
|
77
|
+
|
75
78
|
tmp
|
76
79
|
end
|
77
80
|
|
metadata
CHANGED
@@ -1,58 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: colored2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Wanstrath
|
8
8
|
- Konstantin Gredeskoul
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: rake
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
requirements:
|
18
|
-
- - "~>"
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: '10.0'
|
21
|
-
type: :development
|
22
|
-
prerelease: false
|
23
|
-
version_requirements: !ruby/object:Gem::Requirement
|
24
|
-
requirements:
|
25
|
-
- - "~>"
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
version: '10.0'
|
28
|
-
- !ruby/object:Gem::Dependency
|
29
|
-
name: rspec
|
30
|
-
requirement: !ruby/object:Gem::Requirement
|
31
|
-
requirements:
|
32
|
-
- - "~>"
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version: '3.4'
|
35
|
-
type: :development
|
36
|
-
prerelease: false
|
37
|
-
version_requirements: !ruby/object:Gem::Requirement
|
38
|
-
requirements:
|
39
|
-
- - "~>"
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
version: '3.4'
|
42
|
-
- !ruby/object:Gem::Dependency
|
43
|
-
name: codeclimate-test-reporter
|
44
|
-
requirement: !ruby/object:Gem::Requirement
|
45
|
-
requirements:
|
46
|
-
- - ">="
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: '0'
|
49
|
-
type: :development
|
50
|
-
prerelease: false
|
51
|
-
version_requirements: !ruby/object:Gem::Requirement
|
52
|
-
requirements:
|
53
|
-
- - ">="
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version: '0'
|
12
|
+
date: 2023-08-24 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
56
14
|
description: |+
|
57
15
|
This is a heavily modified fork of http://github.com/defunkt/colored gem, with many
|
58
16
|
sensible pull requests combined. Since the authors of the original gem no longer support it,
|
@@ -89,16 +47,12 @@ files:
|
|
89
47
|
- lib/colored2/object.rb
|
90
48
|
- lib/colored2/strings.rb
|
91
49
|
- lib/colored2/version.rb
|
92
|
-
- spec/colored2/numbers_spec.rb
|
93
|
-
- spec/colored2/object_spec.rb
|
94
|
-
- spec/colored2/strings_spec.rb
|
95
|
-
- spec/colored2_spec.rb
|
96
|
-
- spec/spec_helper.rb
|
97
50
|
homepage: http://github.com/kigster/colored2
|
98
51
|
licenses:
|
99
52
|
- MIT
|
100
|
-
metadata:
|
101
|
-
|
53
|
+
metadata:
|
54
|
+
rubygems_mfa_required: 'true'
|
55
|
+
post_install_message:
|
102
56
|
rdoc_options: []
|
103
57
|
require_paths:
|
104
58
|
- lib
|
@@ -106,21 +60,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
106
60
|
requirements:
|
107
61
|
- - ">="
|
108
62
|
- !ruby/object:Gem::Version
|
109
|
-
version:
|
63
|
+
version: '3.1'
|
110
64
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
65
|
requirements:
|
112
66
|
- - ">="
|
113
67
|
- !ruby/object:Gem::Version
|
114
|
-
version:
|
68
|
+
version: '0'
|
115
69
|
requirements: []
|
116
|
-
|
117
|
-
|
118
|
-
signing_key:
|
70
|
+
rubygems_version: 3.4.13
|
71
|
+
signing_key:
|
119
72
|
specification_version: 4
|
120
73
|
summary: Add even more color to your life.
|
121
|
-
test_files:
|
122
|
-
|
123
|
-
- spec/colored2/object_spec.rb
|
124
|
-
- spec/colored2/strings_spec.rb
|
125
|
-
- spec/colored2_spec.rb
|
126
|
-
- spec/spec_helper.rb
|
74
|
+
test_files: []
|
75
|
+
...
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require File.expand_path('spec/spec_helper')
|
2
|
-
require 'colored2/numbers'
|
3
|
-
require 'colored2/strings'
|
4
|
-
|
5
|
-
RSpec.describe Colored2.integer_class do
|
6
|
-
describe 'with foreground and background colors' do
|
7
|
-
it 'should work with one color' do
|
8
|
-
expect(32.red).to eql('32'.red)
|
9
|
-
end
|
10
|
-
it 'should insert escape sequences' do
|
11
|
-
expect(32.red).to eql("\e[31m32\e[0m")
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
RSpec.describe Float do
|
17
|
-
describe 'with foreground and background colors' do
|
18
|
-
it 'should add two colors chained' do
|
19
|
-
expect((32.5).blue.on.red).to eql('32.5'.blue.on.red)
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'should insert escape sequences' do
|
23
|
-
expect((32.5).blue.on.red).to eql("\e[41m\e[34m32.5\e[0m")
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require File.expand_path('spec/spec_helper')
|
2
|
-
require 'colored2/object'
|
3
|
-
|
4
|
-
subject1 = red('hello')
|
5
|
-
subject2 = red('blue').on.blue
|
6
|
-
subject3 = on.yellow('on yellow')
|
7
|
-
|
8
|
-
RSpec.describe Object do
|
9
|
-
|
10
|
-
describe 'with foreground and background colors' do
|
11
|
-
it 'should work with one color' do
|
12
|
-
expect(subject1).to eql('hello'.red)
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should work with color on color' do
|
16
|
-
expect(subject2).to eql('blue'.red.on.blue)
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'should add background color using on_<color>' do
|
20
|
-
expect(subject3).to eql('on yellow'.on.yellow)
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
@@ -1,77 +0,0 @@
|
|
1
|
-
require File.expand_path('spec/spec_helper')
|
2
|
-
require 'colored2/strings'
|
3
|
-
|
4
|
-
RSpec.describe String do
|
5
|
-
before do
|
6
|
-
Colored2.decorate(String)
|
7
|
-
end
|
8
|
-
|
9
|
-
describe 'with foreground and background colors' do
|
10
|
-
it 'should work with one color' do
|
11
|
-
expect('red'.red).to eql("\e[31mred\e[0m")
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'should add two colors chained' do
|
15
|
-
expect('blue'.red.blue).to eql("\e[34m\e[31mblue\e[0m")
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'should add background color using on_<color>' do
|
19
|
-
expect('on yellow'.on.yellow).to eql("\e[43mon yellow\e[0m")
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'should work with <color>_on_<color> syntax' do
|
23
|
-
expect('red on blue'.red.on.blue).to eql("\e[44m\e[31mred on blue\e[0m")
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe 'with effects' do
|
28
|
-
it 'should add a bold modifier' do
|
29
|
-
expect('way bold'.bold).to eql("\e[1mway bold\e[0m")
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'should let modifiers stack' do
|
33
|
-
expect('underlinedd bold'.bold.underlined).to eql("\e[4m\e[1munderlinedd bold\e[0m")
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'should let modifiers stack with colors' do
|
37
|
-
expect('cyan underlinedd bold'.bold.underlined.cyan).to eql("\e[36m\e[4m\e[1mcyan underlinedd bold\e[0m")
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe 'new block syntax' do
|
42
|
-
it 'should defined block syntax nested colors' do
|
43
|
-
expect('No Color, then'.blue!('blue inside')).to eql('No Color, then' + 'blue inside'.blue)
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'should defined block syntax nested colors two levels deep' do
|
47
|
-
expect('regular here'.blue! + 'blue here'.no_color!).to eql('regular here' << 'blue here'.blue)
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'should defined block syntax nested colors two levels deep' do
|
51
|
-
expect('regular here'.blue! { 'something else'.red!('red riding hood') }).to eql('regular here'.blue! << 'something else'.red! << 'red riding hood'.no_color!)
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'should defined block syntax nested colors two levels deep' do
|
55
|
-
expectation = 'this is regular, but '.red! do
|
56
|
-
'this is red '.yellow! do
|
57
|
-
' and yellow'.no_color!
|
58
|
-
end
|
59
|
-
end
|
60
|
-
expect(expectation).to eql('this is regular, but '.red! << 'this is red '.yellow! << ' and yellow'.no_color!)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe 'end of line' do
|
65
|
-
it 'should work with eol' do
|
66
|
-
expect('nothing to see here really.'.to_eol).to eql("\e[2Knothing to see here really.")
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'should work with eol_with_with_two_colors' do
|
70
|
-
expect('blue'.red.blue.to_eol).to eql("\e[34m\e[31m\e[2Kblue\e[0m")
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'should work with eol_with_modifiers_stack_with_colors' do
|
74
|
-
expect('cyan underlinedd bold'.bold.underlined.cyan.to_eol).to eql("\e[36m\e[4m\e[1m\e[2Kcyan underlinedd bold\e[0m")
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
data/spec/colored2_spec.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'colored2/strings'
|
3
|
-
|
4
|
-
RSpec.describe Colored2 do
|
5
|
-
describe 'global enable and disable' do
|
6
|
-
before do
|
7
|
-
Colored2.disable!
|
8
|
-
end
|
9
|
-
after do
|
10
|
-
Colored2.enable!
|
11
|
-
end
|
12
|
-
let(:sample) { 'sample string' }
|
13
|
-
|
14
|
-
describe 'colors' do
|
15
|
-
subject { sample.red.on.blue }
|
16
|
-
it { should eql(sample) }
|
17
|
-
end
|
18
|
-
describe 'effects' do
|
19
|
-
subject { sample.bold.on.red }
|
20
|
-
it { should eql(sample) }
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|