colorator 0.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +9 -0
- data/History.markdown +21 -0
- data/README.markdown +21 -10
- data/Rakefile +3 -143
- data/colorator.gemspec +17 -60
- data/lib/colorator.rb +94 -1
- data/lib/colorator/core_ext.rb +7 -8
- metadata +16 -38
- data/spec/colorator/core_ext_spec.rb +0 -18
- data/spec/spec_helper.rb +0 -9
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8a17df7703b85003ff47ffcf8e009238af1182b4
|
4
|
+
data.tar.gz: 30aa293378acee4845b2c915fc06058be7f020bd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b865afe608e588b37c68b6b949a64e5b96b3f45dd43cd169a623d4e2b0a1477b7b72c5206979411ad240902d35b0ea64497d31ef8fea3f377fb68931cceef7cf
|
7
|
+
data.tar.gz: 7a223fd8b7747eb86cb310c42ee1c50a09e3c72b74b66935dab90e690767c09e197b029c0bdf22174b2409fa54c7d78cb30145e3d2391d2f0640ea9fd30fea3b
|
data/Gemfile
CHANGED
data/History.markdown
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
## HEAD
|
2
|
+
|
3
|
+
### Major enhancements
|
4
|
+
|
5
|
+
- Merge Simple::ANSI and Colorator. (#7)
|
6
|
+
|
7
|
+
### Minor Enhancements
|
8
|
+
|
9
|
+
- Delete unnecessary `Symbol#to_sym` (#2)
|
10
|
+
- Change argument name of `Enumerator#each` for better code legibility (#3)
|
11
|
+
|
12
|
+
### Bug Fixes
|
13
|
+
|
14
|
+
### Development Fixes
|
15
|
+
|
16
|
+
- Convert to new RSpec expectation syntax (#1)
|
17
|
+
- Fix `String#blue` result in README (#4)
|
18
|
+
|
19
|
+
## 0.1 / 2013-04-13
|
20
|
+
|
21
|
+
Birthday!
|
data/README.markdown
CHANGED
@@ -2,27 +2,38 @@
|
|
2
2
|
|
3
3
|
Colorize your text for the terminal
|
4
4
|
|
5
|
+
[![Build Status](https://travis-ci.org/octopress/colorator.png?branch=master)](https://travis-ci.org/octopress/colorator)
|
6
|
+
|
5
7
|
## Example
|
6
8
|
|
7
9
|
```ruby
|
8
10
|
"this string".red
|
9
11
|
# => \e[31mthis string\e[0m
|
10
12
|
"my string".blue
|
11
|
-
# => \e[
|
13
|
+
# => \e[34mmy string\e[0m
|
12
14
|
# etc...
|
13
15
|
```
|
14
16
|
|
15
17
|
## Supported Colors
|
16
18
|
|
17
|
-
-
|
18
|
-
-
|
19
|
-
- green
|
20
|
-
- yellow
|
21
|
-
-
|
22
|
-
-
|
23
|
-
-
|
24
|
-
-
|
25
|
-
- bold
|
19
|
+
- `red`
|
20
|
+
- `black`
|
21
|
+
- `green`
|
22
|
+
- `yellow`
|
23
|
+
- `magenta`
|
24
|
+
- `white`
|
25
|
+
- `blue`
|
26
|
+
- `cyan`
|
27
|
+
- `bold`
|
28
|
+
|
29
|
+
## Other supported Ansi methods
|
30
|
+
|
31
|
+
- `clear_line`
|
32
|
+
- `has_ansi?`, `has_color?`
|
33
|
+
- `strip_ansi`, `strip_color`
|
34
|
+
- `reset_ansi`, `reset_color`
|
35
|
+
- `clear_screen`
|
36
|
+
- `ansi_jump`
|
26
37
|
|
27
38
|
## Why
|
28
39
|
|
data/Rakefile
CHANGED
@@ -1,146 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require 'date'
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
4
3
|
|
5
|
-
#############################################################################
|
6
|
-
#
|
7
|
-
# Helper functions
|
8
|
-
#
|
9
|
-
#############################################################################
|
10
|
-
|
11
|
-
def name
|
12
|
-
@name ||= Dir['*.gemspec'].first.split('.').first
|
13
|
-
end
|
14
|
-
|
15
|
-
def version
|
16
|
-
line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
|
17
|
-
line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
|
18
|
-
end
|
19
|
-
|
20
|
-
def date
|
21
|
-
Date.today.to_s
|
22
|
-
end
|
23
|
-
|
24
|
-
def rubyforge_project
|
25
|
-
name
|
26
|
-
end
|
27
|
-
|
28
|
-
def gemspec_file
|
29
|
-
"#{name}.gemspec"
|
30
|
-
end
|
31
|
-
|
32
|
-
def gem_file
|
33
|
-
"#{name}-#{version}.gem"
|
34
|
-
end
|
35
|
-
|
36
|
-
def replace_header(head, header_name)
|
37
|
-
head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
|
38
|
-
end
|
39
|
-
|
40
|
-
#############################################################################
|
41
|
-
#
|
42
|
-
# Standard tasks
|
43
|
-
#
|
44
|
-
#############################################################################
|
45
|
-
|
46
|
-
task :default => :spec
|
47
|
-
|
48
|
-
require 'rspec/core/rake_task'
|
49
4
|
RSpec::Core::RakeTask.new(:spec)
|
50
5
|
|
51
|
-
|
52
|
-
task :coverage do
|
53
|
-
require 'rcov'
|
54
|
-
sh "rm -fr coverage"
|
55
|
-
sh "rcov test/test_*.rb"
|
56
|
-
sh "open coverage/index.html"
|
57
|
-
end
|
58
|
-
|
59
|
-
require 'rdoc/task'
|
60
|
-
Rake::RDocTask.new do |rdoc|
|
61
|
-
rdoc.rdoc_dir = 'rdoc'
|
62
|
-
rdoc.title = "#{name} #{version}"
|
63
|
-
rdoc.rdoc_files.include('README*')
|
64
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
65
|
-
end
|
66
|
-
|
67
|
-
desc "Open an irb session preloaded with this library"
|
68
|
-
task :console do
|
69
|
-
sh "irb -rubygems -r ./lib/#{name}.rb"
|
70
|
-
end
|
71
|
-
|
72
|
-
#############################################################################
|
73
|
-
#
|
74
|
-
# Custom tasks (add your own tasks here)
|
75
|
-
#
|
76
|
-
#############################################################################
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
#############################################################################
|
81
|
-
#
|
82
|
-
# Packaging tasks
|
83
|
-
#
|
84
|
-
#############################################################################
|
85
|
-
|
86
|
-
desc "Create tag v#{version} and build and push #{gem_file} to Rubygems"
|
87
|
-
task :release => :build do
|
88
|
-
unless `git branch` =~ /^\* master$/
|
89
|
-
puts "You must be on the master branch to release!"
|
90
|
-
exit!
|
91
|
-
end
|
92
|
-
sh "git commit --allow-empty -a -m 'Release #{version}'"
|
93
|
-
sh "git tag v#{version}"
|
94
|
-
sh "git push origin master"
|
95
|
-
sh "git push origin v#{version}"
|
96
|
-
sh "gem push pkg/#{name}-#{version}.gem"
|
97
|
-
end
|
98
|
-
|
99
|
-
desc "Build #{gem_file} into the pkg directory"
|
100
|
-
task :build => :gemspec do
|
101
|
-
sh "mkdir -p pkg"
|
102
|
-
sh "gem build #{gemspec_file}"
|
103
|
-
sh "mv #{gem_file} pkg"
|
104
|
-
end
|
105
|
-
|
106
|
-
desc "Generate #{gemspec_file}"
|
107
|
-
task :gemspec => :validate do
|
108
|
-
# read spec file and split out manifest section
|
109
|
-
spec = File.read(gemspec_file)
|
110
|
-
head, manifest, tail = spec.split(" # = MANIFEST =\n")
|
111
|
-
|
112
|
-
# replace name version and date
|
113
|
-
replace_header(head, :name)
|
114
|
-
replace_header(head, :version)
|
115
|
-
replace_header(head, :date)
|
116
|
-
#comment this out if your rubyforge_project has a different name
|
117
|
-
replace_header(head, :rubyforge_project)
|
118
|
-
|
119
|
-
# determine file list from git ls-files
|
120
|
-
files = `git ls-files`.
|
121
|
-
split("\n").
|
122
|
-
sort.
|
123
|
-
reject { |file| file =~ /^\./ }.
|
124
|
-
reject { |file| file =~ /^(rdoc|pkg)/ }.
|
125
|
-
map { |file| " #{file}" }.
|
126
|
-
join("\n")
|
127
|
-
|
128
|
-
# piece file back together and write
|
129
|
-
manifest = " s.files = %w[\n#{files}\n ]\n"
|
130
|
-
spec = [head, manifest, tail].join(" # = MANIFEST =\n")
|
131
|
-
File.open(gemspec_file, 'w') { |io| io.write(spec) }
|
132
|
-
puts "Updated #{gemspec_file}"
|
133
|
-
end
|
134
|
-
|
135
|
-
desc "Validate #{gemspec_file}"
|
136
|
-
task :validate do
|
137
|
-
libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
|
138
|
-
unless libfiles.empty?
|
139
|
-
puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
|
140
|
-
exit!
|
141
|
-
end
|
142
|
-
unless Dir['VERSION*'].empty?
|
143
|
-
puts "A `VERSION` file at root level violates Gem best practices."
|
144
|
-
exit!
|
145
|
-
end
|
146
|
-
end
|
6
|
+
task :default => :spec
|
data/colorator.gemspec
CHANGED
@@ -1,66 +1,23 @@
|
|
1
|
-
|
2
|
-
## all of the comments. Some sections require modification, and others can
|
3
|
-
## be deleted if you don't need them. Once you understand the contents of
|
4
|
-
## this file, feel free to delete any comments that begin with two hash marks.
|
5
|
-
## You can find comprehensive Gem::Specification documentation, at
|
6
|
-
## http://docs.rubygems.org/read/chapter/20
|
7
|
-
Gem::Specification.new do |s|
|
8
|
-
s.specification_version = 2 if s.respond_to? :specification_version=
|
9
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
10
|
-
s.rubygems_version = '1.3.5'
|
1
|
+
# coding: utf-8
|
11
2
|
|
12
|
-
|
13
|
-
## If your rubyforge_project name is different, then edit it and comment out
|
14
|
-
## the sub! line in the Rakefile
|
15
|
-
s.name = 'colorator'
|
16
|
-
s.version = '0.1'
|
17
|
-
s.date = '2013-04-13'
|
18
|
-
s.license = 'MIT'
|
3
|
+
require File.expand_path('lib/colorator.rb', __dir__)
|
19
4
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "colorator"
|
7
|
+
spec.summary = "Colorize your text in the terminal."
|
8
|
+
spec.version = Colorator::VERSION
|
9
|
+
spec.authors = ["Parker Moore", "Brandon Mathis"]
|
10
|
+
spec.email = ["parkrmoore@gmail.com", "brandon@imathis.com"]
|
11
|
+
spec.homepage = "https://github.com/octopress/colorator"
|
12
|
+
spec.licenses = ["MIT"]
|
24
13
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
s.email = ["parkrmoore@gmail.com", "brandon@imathis.com"]
|
30
|
-
s.homepage = 'https://github.com/octopress/colorator'
|
14
|
+
all = `git ls-files -z`.split("\x0").reject { |f| f.start_with?(".") }
|
15
|
+
spec.files = all.select { |f| File.basename(f) == f || f =~ %r{^(bin|lib)/} }
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.require_paths = ["lib"]
|
31
18
|
|
32
|
-
|
33
|
-
|
34
|
-
s.require_paths = %w[lib]
|
19
|
+
spec.extra_rdoc_files = ["README.markdown", "LICENSE"]
|
20
|
+
spec.rdoc_options = ["--charset=UTF-8"]
|
35
21
|
|
36
|
-
|
37
|
-
## LICENSE files to the extra_rdoc_files list.
|
38
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
39
|
-
s.extra_rdoc_files = %w[README.markdown LICENSE]
|
40
|
-
|
41
|
-
## List your development dependencies here. Development dependencies are
|
42
|
-
## those that are only needed during development
|
43
|
-
s.add_development_dependency('rake', '~> 10.0')
|
44
|
-
s.add_development_dependency('rspec', '~> 2.13.0')
|
45
|
-
|
46
|
-
## Leave this section as-is. It will be automatically generated from the
|
47
|
-
## contents of your Git repository via the gemspec task. DO NOT REMOVE
|
48
|
-
## THE MANIFEST COMMENTS, they are used as delimiters by the task.
|
49
|
-
# = MANIFEST =
|
50
|
-
s.files = %w[
|
51
|
-
Gemfile
|
52
|
-
LICENSE
|
53
|
-
README.markdown
|
54
|
-
Rakefile
|
55
|
-
colorator.gemspec
|
56
|
-
lib/colorator.rb
|
57
|
-
lib/colorator/core_ext.rb
|
58
|
-
spec/colorator/core_ext_spec.rb
|
59
|
-
spec/spec_helper.rb
|
60
|
-
]
|
61
|
-
# = MANIFEST =
|
62
|
-
|
63
|
-
## Test files will be grabbed from the file list. Make sure the path glob
|
64
|
-
## matches what you actually use.
|
65
|
-
s.test_files = s.files.select { |path| path =~ /^spec\/.*_spec\.rb/ }
|
22
|
+
spec.add_development_dependency "rspec", "~> 3.1"
|
66
23
|
end
|
data/lib/colorator.rb
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
$:.unshift File.dirname(__FILE__)
|
2
2
|
|
3
3
|
module Colorator
|
4
|
-
|
4
|
+
module_function
|
5
|
+
VERSION = "1.0.0"
|
6
|
+
|
7
|
+
# --------------------------------------------------------------------------
|
8
|
+
|
9
|
+
ANSI_MATCHR = /\x1b.*?[jkmsuABGKH]/
|
5
10
|
ANSI_COLORS = {
|
6
11
|
:black => 30,
|
7
12
|
:red => 31,
|
@@ -13,6 +18,94 @@ module Colorator
|
|
13
18
|
:white => 37,
|
14
19
|
:bold => 1
|
15
20
|
}
|
21
|
+
|
22
|
+
# --------------------------------------------------------------------------
|
23
|
+
# Allows you to check if a string currently has ansi.
|
24
|
+
# --------------------------------------------------------------------------
|
25
|
+
|
26
|
+
def has_ansi?(str)
|
27
|
+
str.match(ANSI_MATCHR).is_a?(
|
28
|
+
MatchData
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
# --------------------------------------------------------------------------
|
33
|
+
# Jump the cursor, moving it up and then back down to it's spot, allowing
|
34
|
+
# you to do fancy things like multiple output (downloads) the way that Docker
|
35
|
+
# does them in an async way without breaking term.
|
36
|
+
# --------------------------------------------------------------------------
|
37
|
+
|
38
|
+
def ansi_jump(str, num)
|
39
|
+
"\x1b[#{num}A#{clear_line(str)}\x1b[#{
|
40
|
+
num
|
41
|
+
}B"
|
42
|
+
end
|
43
|
+
|
44
|
+
# --------------------------------------------------------------------------
|
45
|
+
|
46
|
+
def reset_ansi(str = "")
|
47
|
+
"\x1b[0m#{
|
48
|
+
str
|
49
|
+
}"
|
50
|
+
end
|
51
|
+
|
52
|
+
# --------------------------------------------------------------------------
|
53
|
+
|
54
|
+
def clear_line(str = "")
|
55
|
+
"\x1b[2K\r#{
|
56
|
+
str
|
57
|
+
}"
|
58
|
+
end
|
59
|
+
|
60
|
+
# --------------------------------------------------------------------------
|
61
|
+
# Strip ANSI from the current string, making it just a normal string.
|
62
|
+
# --------------------------------------------------------------------------
|
63
|
+
|
64
|
+
def strip_ansi(str)
|
65
|
+
str.gsub(
|
66
|
+
ANSI_MATCHR, ""
|
67
|
+
)
|
68
|
+
end
|
69
|
+
|
70
|
+
# --------------------------------------------------------------------------
|
71
|
+
# Clear the screen's current view, so the user gets a clean output.
|
72
|
+
# --------------------------------------------------------------------------
|
73
|
+
|
74
|
+
def clear_screen(str = "")
|
75
|
+
"\x1b[H\x1b[2J#{
|
76
|
+
str
|
77
|
+
}"
|
78
|
+
end
|
79
|
+
|
80
|
+
# --------------------------------------------------------------------------
|
81
|
+
|
82
|
+
def colorize(str = "", color)
|
83
|
+
"\x1b[#{color}m#{str}\x1b[0m"
|
84
|
+
end
|
85
|
+
|
86
|
+
# --------------------------------------------------------------------------
|
87
|
+
|
88
|
+
Colorator::ANSI_COLORS.each do |color, code|
|
89
|
+
define_method color do |str|
|
90
|
+
colorize(
|
91
|
+
str, code
|
92
|
+
)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
# --------------------------------------------------------------------------
|
97
|
+
|
98
|
+
class << self
|
99
|
+
alias reset_color reset_ansi
|
100
|
+
alias strip_color strip_ansi
|
101
|
+
alias has_color? has_ansi?
|
102
|
+
end
|
103
|
+
|
104
|
+
# --------------------------------------------------------------------------
|
105
|
+
|
106
|
+
CORE_METHODS = (
|
107
|
+
public_methods - Object.methods
|
108
|
+
)
|
16
109
|
end
|
17
110
|
|
18
111
|
require "colorator/core_ext"
|
data/lib/colorator/core_ext.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
class String
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
Colorator::CORE_METHODS.each do |method|
|
3
|
+
define_method method do |*args|
|
4
|
+
Colorator.public_send(method,
|
5
|
+
self, *args
|
6
|
+
)
|
7
|
+
end
|
5
8
|
end
|
6
|
-
|
7
|
-
Colorator::ANSI_COLORS.each do |key, value|
|
8
|
-
define_method(key) { colorize(value) }
|
9
|
-
end
|
10
|
-
end
|
9
|
+
end
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: colorator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Parker Moore
|
@@ -10,41 +9,23 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 2016-04-29 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
16
|
-
name: rake
|
17
|
-
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
|
-
requirements:
|
20
|
-
- - ~>
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '10.0'
|
23
|
-
type: :development
|
24
|
-
prerelease: false
|
25
|
-
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
|
-
requirements:
|
28
|
-
- - ~>
|
29
|
-
- !ruby/object:Gem::Version
|
30
|
-
version: '10.0'
|
31
14
|
- !ruby/object:Gem::Dependency
|
32
15
|
name: rspec
|
33
16
|
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
17
|
requirements:
|
36
|
-
- - ~>
|
18
|
+
- - "~>"
|
37
19
|
- !ruby/object:Gem::Version
|
38
|
-
version:
|
20
|
+
version: '3.1'
|
39
21
|
type: :development
|
40
22
|
prerelease: false
|
41
23
|
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
24
|
requirements:
|
44
|
-
- - ~>
|
25
|
+
- - "~>"
|
45
26
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
47
|
-
description:
|
27
|
+
version: '3.1'
|
28
|
+
description:
|
48
29
|
email:
|
49
30
|
- parkrmoore@gmail.com
|
50
31
|
- brandon@imathis.com
|
@@ -55,39 +36,36 @@ extra_rdoc_files:
|
|
55
36
|
- LICENSE
|
56
37
|
files:
|
57
38
|
- Gemfile
|
39
|
+
- History.markdown
|
58
40
|
- LICENSE
|
59
41
|
- README.markdown
|
60
42
|
- Rakefile
|
61
43
|
- colorator.gemspec
|
62
44
|
- lib/colorator.rb
|
63
45
|
- lib/colorator/core_ext.rb
|
64
|
-
- spec/colorator/core_ext_spec.rb
|
65
|
-
- spec/spec_helper.rb
|
66
46
|
homepage: https://github.com/octopress/colorator
|
67
47
|
licenses:
|
68
48
|
- MIT
|
49
|
+
metadata: {}
|
69
50
|
post_install_message:
|
70
51
|
rdoc_options:
|
71
|
-
- --charset=UTF-8
|
52
|
+
- "--charset=UTF-8"
|
72
53
|
require_paths:
|
73
54
|
- lib
|
74
55
|
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
-
none: false
|
76
56
|
requirements:
|
77
|
-
- -
|
57
|
+
- - ">="
|
78
58
|
- !ruby/object:Gem::Version
|
79
59
|
version: '0'
|
80
60
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
61
|
requirements:
|
83
|
-
- -
|
62
|
+
- - ">="
|
84
63
|
- !ruby/object:Gem::Version
|
85
64
|
version: '0'
|
86
65
|
requirements: []
|
87
66
|
rubyforge_project:
|
88
|
-
rubygems_version:
|
67
|
+
rubygems_version: 2.5.1
|
89
68
|
signing_key:
|
90
|
-
specification_version:
|
91
|
-
summary:
|
92
|
-
test_files:
|
93
|
-
- spec/colorator/core_ext_spec.rb
|
69
|
+
specification_version: 4
|
70
|
+
summary: Colorize your text in the terminal.
|
71
|
+
test_files: []
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe String do
|
4
|
-
let(:string) { "i am a test string, y'know?" }
|
5
|
-
|
6
|
-
it "contains all the methods from Colorator::ANSI_COLORS" do
|
7
|
-
Colorator::ANSI_COLORS.keys.each do |color|
|
8
|
-
string.methods.should include(color)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
it "colors the text properly" do
|
13
|
-
Colorator::ANSI_COLORS.each do |color, code|
|
14
|
-
string.send(color.to_sym).should include(code.to_s)
|
15
|
-
string.send(color.to_sym).should eq("\e[#{code}m#{string}\e[0m")
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
data/spec/spec_helper.rb
DELETED