colored2 2.0.2 → 3.1.2
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/README.md +75 -13
- data/lib/colored2.rb +18 -10
- data/lib/colored2/ascii_decorator.rb +12 -27
- data/lib/colored2/codes.rb +63 -0
- data/lib/colored2/numbers.rb +10 -2
- data/lib/colored2/object.rb +1 -1
- data/lib/colored2/strings.rb +1 -1
- data/lib/colored2/version.rb +1 -1
- data/spec/colored2/numbers_spec.rb +26 -0
- data/spec/{colored2_object_spec.rb → colored2/object_spec.rb} +2 -2
- data/spec/{colored2_string_spec.rb → colored2/strings_spec.rb} +6 -6
- data/spec/spec_helper.rb +2 -2
- metadata +12 -12
- data/lib/colored2/constants.rb +0 -23
- data/spec/colored2_numbers_spec.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 924031901113f03f0694ea75208745920d7f38ab
|
4
|
+
data.tar.gz: 835ee416fa88d5d903546a021da1e0792d6529fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '008631053e811a6694c199ddc6c0c5b2636c7c863a5a794835766effb93cb9afea9af5a51802f8b9943a206138b9555002b33e68eeb148b9f05ded8fc6fe2f5f'
|
7
|
+
data.tar.gz: a3d40c57634d3753a2dcd9073f6841ef2f40d1b21b1a141a34ade7eff762a934e878f2e8b91051c0f072e8b392cff5abd77456b6415d2d0cb4f28fbcb4c473f8
|
data/README.md
CHANGED
@@ -1,31 +1,93 @@
|
|
1
1
|
[](https://badge.fury.io/rb/colored2)
|
2
|
+
[](https://rubygems.org/gems/colored2)
|
3
|
+
[](https://gitter.im/colored2)
|
4
|
+
|
2
5
|
[](https://travis-ci.org/kigster/colored2)
|
3
|
-
[](https://codeclimate.com/github/kigster/colored2/coverage)
|
7
|
+
[](https://codeclimate.com/github/kigster/colored2)
|
8
|
+
[](https://codeclimate.com/github/kigster/colored2)
|
6
9
|
|
7
10
|
## Colored2
|
8
11
|
|
9
|
-
This is
|
12
|
+
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.
|
10
13
|
|
11
|
-
This fork comes with a slightly spruced up syntax and
|
14
|
+
This fork comes with a slightly spruced up syntax, some additional features, and a test suite written in [RSpec](http://rspec.info/).
|
12
15
|
|
13
16
|
## Usage
|
14
17
|
|
15
|
-
In addition to the simple syntax of the original gem, which affected only the string to the left of the method call,
|
16
|
-
|
17
|
-
|
18
|
-
or argument is provided, the color is left open-ended, and must be explicitly reset – when using the 'bang' notation.
|
18
|
+
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.
|
19
|
+
|
20
|
+
If no block or argument is provided, the color is left open-ended, and must be explicitly reset – when using the 'bang' notation.
|
19
21
|
|
20
22
|

|
21
23
|
|
24
|
+
### Complete set of colors:
|
25
|
+
|
26
|
+
* black
|
27
|
+
* red
|
28
|
+
* green
|
29
|
+
* yellow
|
30
|
+
* blue
|
31
|
+
* magenta
|
32
|
+
* cyan
|
33
|
+
* white
|
34
|
+
|
35
|
+
### Complete Set of Effects
|
36
|
+
|
37
|
+
> Note: previous versions used method name `clear` instead of `no_color`, which clashed with many 3rd party frameworks that defined similarly named method in the global namespace.
|
38
|
+
> This highlights the dangers of introducing so many words into the `String` namespace.
|
39
|
+
|
40
|
+
* no_color
|
41
|
+
* bold
|
42
|
+
* dark
|
43
|
+
* italic
|
44
|
+
* underlined
|
45
|
+
* reversed
|
46
|
+
* plain
|
47
|
+
* normal
|
48
|
+
|
22
49
|
## Usage in Other Classes
|
23
50
|
|
24
|
-
|
51
|
+
With this gem you can add color to not just strings, but to any other class. `String` class is automatically decorated as soon as `require 'colored2'` is parsed by the ruby interpreter. Note that future versions may refrain from auto-requiring `colored2/strings`, and rely on explicitly requiring components they need colorized, eg `require 'colored2/numbers'`.
|
25
52
|
|
26
|
-
To color numbers, require the following file, which automatically decorates `
|
27
|
-
to the `Object`. Finally, you can add the methods to any custom class by including the `Colored2` Module.
|
53
|
+
To color numbers, require the following file, which automatically decorates `Integer` and `Float`. You can also add color methods to the `Object`. Finally, you can add the methods to any custom class by including the `Colored2` Module.
|
28
54
|
|
29
|
-
Below is an `IRB` session that shows a slightly more advanced usage.
|
55
|
+
Below is an `IRB` — session that shows a slightly more advanced usage.
|
30
56
|
|
31
57
|

|
58
|
+
|
59
|
+
## Additional Helpers
|
60
|
+
|
61
|
+
There are several additional helpers tucked onto the `String` class.
|
62
|
+
|
63
|
+
* `#to_bol` (to beginning of the line) will rewind the cursor back to the beginning of the current line.
|
64
|
+
* `#to_eol` (to end of line)
|
65
|
+
|
66
|
+
## Installation
|
67
|
+
|
68
|
+
Add this line to your application's Gemfile:
|
69
|
+
|
70
|
+
|
71
|
+
gem 'colored2'
|
72
|
+
|
73
|
+
|
74
|
+
And then execute:
|
75
|
+
|
76
|
+
$ bundle
|
77
|
+
|
78
|
+
Or install it yourself as:
|
79
|
+
|
80
|
+
$ gem install colored2
|
81
|
+
|
82
|
+
|
83
|
+
## Development
|
84
|
+
|
85
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
86
|
+
|
87
|
+
## Contributing
|
88
|
+
|
89
|
+
Bug reports and pull requests are welcome on GitHub at [https://github.com/kigster/colored2](https://github.com/kigster/colored2).
|
90
|
+
|
91
|
+
## License
|
92
|
+
|
93
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/lib/colored2.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'colored2/
|
1
|
+
require 'colored2/codes'
|
2
2
|
require 'colored2/ascii_decorator'
|
3
3
|
|
4
4
|
module Colored2
|
@@ -9,23 +9,27 @@ module Colored2
|
|
9
9
|
def self.included(from_class)
|
10
10
|
from_class.class_eval do
|
11
11
|
|
12
|
-
def surround_with_color(
|
13
|
-
color_type = if Colored2.background_next?
|
12
|
+
def surround_with_color(color: nil, effect: nil, color_self: nil, string: nil, &block)
|
13
|
+
color_type = if Colored2.background_next? && effect.nil?
|
14
14
|
Colored2.foreground_next!
|
15
15
|
:background
|
16
16
|
else
|
17
17
|
:foreground
|
18
18
|
end
|
19
19
|
|
20
|
+
opts = {}
|
21
|
+
opts.merge!(color_type => color) if color
|
22
|
+
opts.merge!(effect: effect) if effect
|
23
|
+
|
20
24
|
if color_self then
|
21
|
-
opts
|
25
|
+
opts.merge!( beginning: :on, end: :off)
|
22
26
|
colored = Colored2::AsciiDecorator.new(self).decorate(opts)
|
23
27
|
if string || block
|
24
28
|
arg = "#{string}#{block.call if block}"
|
25
29
|
colored << Colored2::AsciiDecorator.new(arg).decorate(opts) if arg.length > 0
|
26
30
|
end
|
27
31
|
else
|
28
|
-
opts
|
32
|
+
opts.merge!( end: :on )
|
29
33
|
colored = Colored2::AsciiDecorator.new(self).decorate(opts)
|
30
34
|
if string || block
|
31
35
|
arg = "#{string}#{block.call if block}"
|
@@ -44,22 +48,22 @@ module Colored2
|
|
44
48
|
from_class.instance_eval do
|
45
49
|
COLORS.keys.each do |color|
|
46
50
|
define_method(color) do |string = nil, &block|
|
47
|
-
surround_with_color(color, true, string, &block)
|
51
|
+
surround_with_color(color: color, color_self: true, string: string, &block)
|
48
52
|
end
|
49
53
|
|
50
54
|
define_method("#{color}!".to_sym) do |string = nil, &block|
|
51
|
-
surround_with_color(color, false, string, &block)
|
55
|
+
surround_with_color(color: color, color_self: false, string: string, &block)
|
52
56
|
end
|
53
57
|
end
|
54
58
|
|
55
59
|
EFFECTS.keys.each do |effect|
|
56
|
-
next if effect == '
|
60
|
+
next if effect == 'no_color'
|
57
61
|
define_method(effect) do |string = nil, &block|
|
58
|
-
surround_with_color(effect, true, string, &block)
|
62
|
+
surround_with_color(effect: effect, color_self: true, string: string, &block)
|
59
63
|
end
|
60
64
|
|
61
65
|
define_method("#{effect}!".to_sym) do |string = nil, &block|
|
62
|
-
surround_with_color(effect, false, string, &block)
|
66
|
+
surround_with_color(effect: effect, color_self: false, string: string, &block)
|
63
67
|
end
|
64
68
|
end
|
65
69
|
|
@@ -70,6 +74,10 @@ module Colored2
|
|
70
74
|
end
|
71
75
|
tmp
|
72
76
|
end
|
77
|
+
|
78
|
+
define_method(:to_bol) do
|
79
|
+
"#{self}\033[#{length}D\033[0D"
|
80
|
+
end
|
73
81
|
end
|
74
82
|
end
|
75
83
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require 'colored2/codes'
|
2
2
|
require 'forwardable'
|
3
3
|
|
4
4
|
module Colored2
|
@@ -41,29 +41,10 @@ module Colored2
|
|
41
41
|
def background_next?
|
42
42
|
self.__background_next
|
43
43
|
end
|
44
|
-
|
45
|
-
def clear
|
46
|
-
effect(:clear)
|
47
|
-
end
|
48
|
-
|
49
|
-
def colors
|
50
|
-
@colors ||= COLORS.keys.sort
|
51
|
-
end
|
52
|
-
|
53
|
-
def effect(effect_name)
|
54
|
-
"\e[#{EFFECTS[effect_name]}m" if effect_name && EFFECTS[effect_name.to_sym]
|
55
|
-
end
|
56
|
-
|
57
|
-
def color(color_name:, type:)
|
58
|
-
background_code = (type == :background) ? 10 : 0
|
59
|
-
if color_name && COLORS[color_name.to_sym]
|
60
|
-
"\e[#{COLORS[color_name.to_sym] + background_code}m"
|
61
|
-
end
|
62
|
-
end
|
63
44
|
end
|
64
45
|
|
65
46
|
extend Forwardable
|
66
|
-
def_delegators :@my_class, :enable!, :disable
|
47
|
+
def_delegators :@my_class, :enable!, :disable!
|
67
48
|
|
68
49
|
attr_accessor :string, :my_class
|
69
50
|
|
@@ -73,21 +54,20 @@ module Colored2
|
|
73
54
|
end
|
74
55
|
|
75
56
|
# options[:start] = :color
|
76
|
-
# options[:end] = :color | :
|
57
|
+
# options[:end] = :color | :no_color
|
77
58
|
def decorate(options = {})
|
78
|
-
|
79
59
|
return string if !self.class.enabled? || string.length == 0
|
80
60
|
escape_sequence = [
|
81
|
-
|
82
|
-
|
83
|
-
|
61
|
+
Colored2::TextColor.new(options[:foreground]),
|
62
|
+
Colored2::BackgroundColor.new(options[:background]),
|
63
|
+
Colored2::Effect.new(options[:effect])
|
84
64
|
].compact.join
|
85
65
|
|
86
66
|
colored = ''
|
87
67
|
colored << escape_sequence if options[:beginning] == :on
|
88
68
|
colored << string
|
89
69
|
if options[:end]
|
90
|
-
colored <<
|
70
|
+
colored << no_color if options[:end] == :off && !colored.end_with?(no_color)
|
91
71
|
colored << escape_sequence if options[:end] == :on
|
92
72
|
end
|
93
73
|
colored
|
@@ -97,5 +77,10 @@ module Colored2
|
|
97
77
|
string.gsub(%r{\e\[\d+(;\d+)*m}, '')
|
98
78
|
end
|
99
79
|
|
80
|
+
private
|
81
|
+
|
82
|
+
def no_color
|
83
|
+
@no_color ||= Colored2::Effect.new(:no_color).to_s
|
84
|
+
end
|
100
85
|
end
|
101
86
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Colored2
|
2
|
+
|
3
|
+
COLORS = {
|
4
|
+
black: 30,
|
5
|
+
red: 31,
|
6
|
+
green: 32,
|
7
|
+
yellow: 33,
|
8
|
+
blue: 34,
|
9
|
+
magenta: 35,
|
10
|
+
cyan: 36,
|
11
|
+
white: 37
|
12
|
+
}
|
13
|
+
|
14
|
+
EFFECTS = {
|
15
|
+
no_color: 0,
|
16
|
+
bold: 1,
|
17
|
+
dark: 2,
|
18
|
+
italic: 3,
|
19
|
+
underlined: 4,
|
20
|
+
reversed: 7,
|
21
|
+
plain: 21, # non-bold
|
22
|
+
normal: 22
|
23
|
+
}
|
24
|
+
|
25
|
+
class Code
|
26
|
+
attr_accessor :name, :escape
|
27
|
+
def initialize(name)
|
28
|
+
@name = name
|
29
|
+
return if name.nil?
|
30
|
+
@escape = codes[name.to_sym]
|
31
|
+
raise ArgumentError.new("No color or effect named #{name} exists for #{self.class}.") if @escape.nil?
|
32
|
+
end
|
33
|
+
|
34
|
+
def value(shift = nil)
|
35
|
+
escape_code = escape
|
36
|
+
escape_code += shift if shift && escape_code
|
37
|
+
name && escape ? "\e[#{escape_code}m" : ''
|
38
|
+
end
|
39
|
+
|
40
|
+
def to_s
|
41
|
+
value
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class Effect < Code
|
46
|
+
def codes
|
47
|
+
EFFECTS
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class TextColor < Code
|
52
|
+
def codes
|
53
|
+
COLORS
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class BackgroundColor < TextColor
|
58
|
+
def value
|
59
|
+
super 10
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
data/lib/colored2/numbers.rb
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
-
require 'colored2'
|
2
|
-
|
1
|
+
require 'colored2' unless defined?(Colored2) && Colored2.respond_to?(:decorate)
|
2
|
+
|
3
|
+
module Colored2
|
4
|
+
def self.integer_class
|
5
|
+
major, minor = RUBY_VERSION.split(/\./).map(&:to_i)
|
6
|
+
major >= 2 && minor >= 4 ? Integer : Kernel.const_get(:Fixnum)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
Colored2.decorate(Colored2.integer_class)
|
3
11
|
Colored2.decorate(Float)
|
data/lib/colored2/object.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require 'colored2'
|
1
|
+
require 'colored2' unless defined?(Colored2) && Colored2.respond_to?(:decorate)
|
2
2
|
Colored2.decorate(Object)
|
data/lib/colored2/strings.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require 'colored2'
|
1
|
+
require 'colored2' unless defined?(Colored2) && Colored2.respond_to?(:decorate)
|
2
2
|
Colored2.decorate(String)
|
data/lib/colored2/version.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
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,5 +1,5 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require File.expand_path('spec/spec_helper')
|
2
|
+
require 'colored2/strings'
|
3
3
|
|
4
4
|
RSpec.describe String do
|
5
5
|
before do
|
@@ -44,20 +44,20 @@ RSpec.describe String do
|
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'should defined block syntax nested colors two levels deep' do
|
47
|
-
expect('regular here'.blue! + 'blue here'.
|
47
|
+
expect('regular here'.blue! + 'blue here'.no_color!).to eql('regular here' << 'blue here'.blue)
|
48
48
|
end
|
49
49
|
|
50
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'.
|
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
52
|
end
|
53
53
|
|
54
54
|
it 'should defined block syntax nested colors two levels deep' do
|
55
55
|
expectation = 'this is regular, but '.red! do
|
56
56
|
'this is red '.yellow! do
|
57
|
-
' and yellow'.
|
57
|
+
' and yellow'.no_color!
|
58
58
|
end
|
59
59
|
end
|
60
|
-
expect(expectation).to eql('this is regular, but '.red! << 'this is red '.yellow! << ' and yellow'.
|
60
|
+
expect(expectation).to eql('this is regular, but '.red! << 'this is red '.yellow! << ' and yellow'.no_color!)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: colored2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Wanstrath
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-02-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -67,10 +67,10 @@ description: |+
|
|
67
67
|
puts 'this is red with and italic'.red.italic
|
68
68
|
puts 'this is green bold'.green.bold << ' and regular'.green
|
69
69
|
puts 'this is really bold blue on white but reversed'.bold.blue.on.white.reversed
|
70
|
-
puts 'this is regular, but '.red! << 'this is red '.yellow! << ' and yellow.'.
|
70
|
+
puts 'this is regular, but '.red! << 'this is red '.yellow! << ' and yellow.'.no_color!
|
71
71
|
puts ('this is regular, but '.red! do
|
72
72
|
'this is red '.yellow! do
|
73
|
-
' and yellow.'.
|
73
|
+
' and yellow.'.no_color!
|
74
74
|
end
|
75
75
|
end)
|
76
76
|
|
@@ -84,15 +84,15 @@ files:
|
|
84
84
|
- Rakefile
|
85
85
|
- lib/colored2.rb
|
86
86
|
- lib/colored2/ascii_decorator.rb
|
87
|
-
- lib/colored2/
|
87
|
+
- lib/colored2/codes.rb
|
88
88
|
- lib/colored2/numbers.rb
|
89
89
|
- lib/colored2/object.rb
|
90
90
|
- lib/colored2/strings.rb
|
91
91
|
- lib/colored2/version.rb
|
92
|
-
- spec/
|
93
|
-
- spec/
|
92
|
+
- spec/colored2/numbers_spec.rb
|
93
|
+
- spec/colored2/object_spec.rb
|
94
|
+
- spec/colored2/strings_spec.rb
|
94
95
|
- spec/colored2_spec.rb
|
95
|
-
- spec/colored2_string_spec.rb
|
96
96
|
- spec/spec_helper.rb
|
97
97
|
homepage: http://github.com/kigster/colored2
|
98
98
|
licenses:
|
@@ -114,13 +114,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
114
|
version: 1.3.6
|
115
115
|
requirements: []
|
116
116
|
rubyforge_project:
|
117
|
-
rubygems_version: 2.
|
117
|
+
rubygems_version: 2.6.8
|
118
118
|
signing_key:
|
119
119
|
specification_version: 4
|
120
120
|
summary: Add even more color to your life.
|
121
121
|
test_files:
|
122
|
-
- spec/
|
123
|
-
- spec/
|
122
|
+
- spec/colored2/numbers_spec.rb
|
123
|
+
- spec/colored2/object_spec.rb
|
124
|
+
- spec/colored2/strings_spec.rb
|
124
125
|
- spec/colored2_spec.rb
|
125
|
-
- spec/colored2_string_spec.rb
|
126
126
|
- spec/spec_helper.rb
|
data/lib/colored2/constants.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
module Colored2
|
2
|
-
COLORS = {
|
3
|
-
black: 30,
|
4
|
-
red: 31,
|
5
|
-
green: 32,
|
6
|
-
yellow: 33,
|
7
|
-
blue: 34,
|
8
|
-
magenta: 35,
|
9
|
-
cyan: 36,
|
10
|
-
white: 37
|
11
|
-
}
|
12
|
-
EFFECTS = {
|
13
|
-
clear: 0,
|
14
|
-
bold: 1,
|
15
|
-
dark: 2,
|
16
|
-
italic: 3,
|
17
|
-
underlined: 4,
|
18
|
-
reversed: 7,
|
19
|
-
plain: 21, # non-bold
|
20
|
-
normal: 22
|
21
|
-
}
|
22
|
-
ESCAPES = COLORS.merge(EFFECTS)
|
23
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require_relative 'spec_helper'
|
2
|
-
require_relative '../lib/colored2/numbers'
|
3
|
-
require_relative '../lib/colored2/strings'
|
4
|
-
|
5
|
-
RSpec.describe Fixnum 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
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
RSpec.describe Float do
|
14
|
-
describe 'with foreground and background colors' do
|
15
|
-
it 'should add two colors chained' do
|
16
|
-
expect((32.5).blue.on.red).to eql('32.5'.blue.on.red)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|