iron-term-ansicolor 0.0.1
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.
- data/README.rdoc +16 -0
- data/Rakefile +226 -0
- data/iron-term-ansicolor.gemspec +32 -0
- data/lib/iron-term-ansicolor.rb +73 -0
- data/spec/iron-term-ansicolor_simple_background_spec.rb +73 -0
- data/spec/iron-term-ansicolor_simple_foreground_spec.rb +73 -0
- data/spec/spec_helper.rb +10 -0
- metadata +73 -0
data/README.rdoc
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
= iron-term-ansicolor
|
2
|
+
|
3
|
+
iron-term-console is a library for IronRuby that makes use of the .Net framework
|
4
|
+
System.Console and related classes to provide colored output for ANSI formatted
|
5
|
+
strings.
|
6
|
+
|
7
|
+
For the Ruby OneClick installer, a package called win32console exists to provide
|
8
|
+
this functionality. It makes calls to the Win32 API, including bit twiddling,
|
9
|
+
to provide colored console output for that Ruby distribution. In IronRuby, we
|
10
|
+
have direct access to the .Net Base Class Library. Rather than writing C# code
|
11
|
+
to create an IronRuby module to interact with a C++ API, this library directly
|
12
|
+
uses the .Net BCL, and write the code directly in Ruby.
|
13
|
+
|
14
|
+
== Copyright
|
15
|
+
|
16
|
+
Copyright (c) 2009 Will Green, Ivan Porto Carrero, David Blackmon. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,226 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'rake/rdoctask'
|
5
|
+
require 'lib/iron-term-ansicolor'
|
6
|
+
begin
|
7
|
+
require 'jeweler'
|
8
|
+
Jeweler::Tasks.new do |gem|
|
9
|
+
gem.name = "iron-term-ansicolor"
|
10
|
+
gem.summary = %Q{TODO}
|
11
|
+
gem.email = "will@hotgazpacho.org"
|
12
|
+
gem.homepage = "http://github.com/hotgazpacho/iron-term-ansicolor"
|
13
|
+
gem.authors = ["hotgazpacho","casualjim"]
|
14
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
+
end
|
16
|
+
|
17
|
+
rescue LoadError
|
18
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'spec/rake/spectask'
|
22
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
23
|
+
spec.libs << 'lib' << 'spec'
|
24
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
25
|
+
end
|
26
|
+
|
27
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
28
|
+
spec.libs << 'lib' << 'spec'
|
29
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
30
|
+
spec.rcov = true
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
task :default => :spec
|
35
|
+
|
36
|
+
|
37
|
+
##############################################################################
|
38
|
+
# OPTIONS
|
39
|
+
##############################################################################
|
40
|
+
|
41
|
+
PKG_NAME = 'iron-term-ansicolor'
|
42
|
+
PKG_VERSION = if File.exist?('VERSION.yml')
|
43
|
+
config = YAML.load(File.read('VERSION.yml'))
|
44
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
45
|
+
else
|
46
|
+
version = IronTermAnsiColor::Version::STRING
|
47
|
+
end
|
48
|
+
AUTHORS = ['Will Green', 'David Blackmon', 'Ivan Porto Carrero']
|
49
|
+
EMAIL = "will@hotgazpacho.org"
|
50
|
+
HOMEPAGE = "http://github.com/hotgazpacho/iron-term-ansicolor"
|
51
|
+
SUMMARY = "iron-term-ansicolor brings color output for RSpec and the likes to IronRuby."
|
52
|
+
|
53
|
+
# These are the common rdoc options that are shared between generation of
|
54
|
+
# rdoc files using BOTH 'rake rdoc' and the installation by users of a
|
55
|
+
# RubyGem version which builds rdoc's along with its installation. Any
|
56
|
+
# rdoc options that are ONLY for developers running 'rake rdoc' should be
|
57
|
+
# added in the 'Rake::RDocTask' block below.
|
58
|
+
RDOC_OPTIONS = [
|
59
|
+
"--quiet",
|
60
|
+
"--title", SUMMARY,
|
61
|
+
"--main", "README.rdoc",
|
62
|
+
"--line-numbers",
|
63
|
+
"--format","darkfish"
|
64
|
+
]
|
65
|
+
|
66
|
+
# Extra files outside of the lib dir that should be included with the rdocs.
|
67
|
+
RDOC_FILES = (%w( README.rdoc)).sort
|
68
|
+
|
69
|
+
# The full file list used for rdocs, tarballs, gems, and for generating the xmpp4r.gemspec.
|
70
|
+
PKG_FILES = (%w( Rakefile iron-term-ansicolor.gemspec ) + RDOC_FILES + Dir["{lib,spec}/**/*"]).sort
|
71
|
+
|
72
|
+
# RDOC
|
73
|
+
#######
|
74
|
+
Rake::RDocTask.new do |rd|
|
75
|
+
|
76
|
+
# which dir should rdoc files be installed in?
|
77
|
+
rd.rdoc_dir = 'rdoc'
|
78
|
+
rd.title = "iron-term-ansicolor #{PKG_VERSION}"
|
79
|
+
|
80
|
+
# the full list of files to be included
|
81
|
+
rd.rdoc_files.include('README*')
|
82
|
+
rd.rdoc_files.include(RDOC_FILES, "lib/**/*.rb")
|
83
|
+
|
84
|
+
# the full list of options that are common between gem build
|
85
|
+
# and 'rake rdoc' build of docs.
|
86
|
+
rd.options = RDOC_OPTIONS
|
87
|
+
|
88
|
+
# Devs Only : Uncomment to also document private methods in the rdocs
|
89
|
+
# Please don't check this change in to the source repo.
|
90
|
+
#rd.options << '--all'
|
91
|
+
|
92
|
+
# Devs Only : Uncomment to generate dot (graphviz) diagrams along with rdocs.
|
93
|
+
# This requires that graphiz (dot) be installed as a local binary and on your path.
|
94
|
+
# See : http://www.graphviz.org/
|
95
|
+
# Please don't check this change in to the source repo as it introduces a binary dependency.
|
96
|
+
#rd.options << '--diagram'
|
97
|
+
#rd.options << '--fileboxes'
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
##############################################################################
|
102
|
+
# PACKAGING & INSTALLATION
|
103
|
+
##############################################################################
|
104
|
+
|
105
|
+
# What files/dirs should 'rake clean' remove?
|
106
|
+
#CLEAN.include ["*.gem", "pkg", "rdoc", "coverage"]
|
107
|
+
|
108
|
+
begin
|
109
|
+
require 'rake/gempackagetask'
|
110
|
+
|
111
|
+
spec = Gem::Specification.new do |s|
|
112
|
+
s.name = PKG_NAME
|
113
|
+
s.version = PKG_VERSION
|
114
|
+
s.authors = AUTHORS
|
115
|
+
s.email = EMAIL
|
116
|
+
s.homepage = HOMEPAGE
|
117
|
+
s.rubyforge_project = PKG_NAME
|
118
|
+
s.summary = SUMMARY
|
119
|
+
s.description = s.summary
|
120
|
+
s.platform = Gem::Platform::RUBY
|
121
|
+
s.require_path = 'lib'
|
122
|
+
s.executables = []
|
123
|
+
s.files = PKG_FILES
|
124
|
+
s.test_files = []
|
125
|
+
s.has_rdoc = true
|
126
|
+
s.extra_rdoc_files = RDOC_FILES
|
127
|
+
s.rdoc_options = RDOC_OPTIONS
|
128
|
+
s.required_ruby_version = ">= 1.8.6"
|
129
|
+
s.add_dependency 'term-ansicolor', ">= 1.0.4"
|
130
|
+
end
|
131
|
+
|
132
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
133
|
+
pkg.gem_spec = spec
|
134
|
+
pkg.need_tar = true
|
135
|
+
pkg.need_zip = true
|
136
|
+
end
|
137
|
+
|
138
|
+
namespace :gem do
|
139
|
+
|
140
|
+
desc "Run :package and install the .gem locally"
|
141
|
+
task :install => [:update_gemspec, :package] do
|
142
|
+
sh %{sudo gem install --local pkg/#{PKG_NAME}-#{PKG_VERSION}.gem}
|
143
|
+
end
|
144
|
+
|
145
|
+
desc "Like gem:install but without ri or rdocs"
|
146
|
+
task :install_fast => [:update_gemspec, :package] do
|
147
|
+
sh %{sudo gem install --local pkg/#{PKG_NAME}-#{PKG_VERSION}.gem --no-rdoc --no-ri}
|
148
|
+
end
|
149
|
+
|
150
|
+
desc "Run :clean and uninstall the .gem"
|
151
|
+
task :uninstall => :clean do
|
152
|
+
sh %{sudo gem uninstall #{PKG_NAME}}
|
153
|
+
end
|
154
|
+
|
155
|
+
# Thanks to the Merb project for this code.
|
156
|
+
desc "Update Github Gemspec"
|
157
|
+
task :update_gemspec do
|
158
|
+
skip_fields = %w(new_platform original_platform date)
|
159
|
+
|
160
|
+
result = "# WARNING : RAKE AUTO-GENERATED FILE. DO NOT MANUALLY EDIT!\n"
|
161
|
+
result << "# RUN : 'rake gem:update_gemspec'\n\n"
|
162
|
+
result << "Gem::Specification.new do |s|\n"
|
163
|
+
spec.instance_variables.sort.each do |ivar|
|
164
|
+
value = spec.instance_variable_get(ivar)
|
165
|
+
name = ivar.to_s.split("@").last
|
166
|
+
next if skip_fields.include?(name) || value.nil? || value == "" || (value.respond_to?(:empty?) && value.empty?)
|
167
|
+
if name == "dependencies"
|
168
|
+
value.each do |d|
|
169
|
+
dep, *ver = d.to_s.split(" ")
|
170
|
+
result << " s.add_dependency #{dep.inspect}, #{ver.join(" ").inspect.gsub(/[()]/, "")}\n"
|
171
|
+
end
|
172
|
+
else
|
173
|
+
case value
|
174
|
+
when Array
|
175
|
+
value = name != "files" ? value.inspect : value.sort.uniq.inspect.split(",").join(",\n")
|
176
|
+
when String, Fixnum, true, false
|
177
|
+
value = value.inspect
|
178
|
+
else
|
179
|
+
value = value.to_s.inspect
|
180
|
+
end
|
181
|
+
result << " s.#{name} = #{value}\n"
|
182
|
+
end
|
183
|
+
end
|
184
|
+
result << "end"
|
185
|
+
File.open(File.join(File.dirname(__FILE__), "#{spec.name}.gemspec"), "w"){|f| f << result}
|
186
|
+
end
|
187
|
+
|
188
|
+
end # namespace :gem
|
189
|
+
|
190
|
+
# also keep the gemspec up to date each time we package a tarball or gem
|
191
|
+
task :package => ['gem:update_gemspec']
|
192
|
+
task :gem => ['gem:update_gemspec']
|
193
|
+
|
194
|
+
rescue LoadError
|
195
|
+
puts <<EOF
|
196
|
+
###
|
197
|
+
Packaging Warning : RubyGems is apparently not installed on this
|
198
|
+
system and any file add/remove/rename will not
|
199
|
+
be auto-updated in the 'iron-term-ansicolor.gemspec' when you run any
|
200
|
+
package tasks. All such file changes are recommended
|
201
|
+
to be packaged on a system with RubyGems installed
|
202
|
+
if you intend to push commits to the Git repo so the
|
203
|
+
gemspec will also stay in sync for others.
|
204
|
+
###
|
205
|
+
EOF
|
206
|
+
end
|
207
|
+
|
208
|
+
# we are apparently on a system that does not have RubyGems installed.
|
209
|
+
# Lets try to provide only the basic tarball package tasks as a fallback.
|
210
|
+
unless defined? Gem
|
211
|
+
begin
|
212
|
+
require 'rake/packagetask'
|
213
|
+
Rake::PackageTask.new(PKG_NAME, PKG_VERSION) do |p|
|
214
|
+
p.package_files = PKG_FILES
|
215
|
+
p.need_tar = true
|
216
|
+
p.need_zip = true
|
217
|
+
end
|
218
|
+
rescue LoadError
|
219
|
+
puts <<EOF
|
220
|
+
###
|
221
|
+
Warning : Unable to require the 'rake/packagetask'. Is Rake installed?
|
222
|
+
###
|
223
|
+
EOF
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# WARNING : RAKE AUTO-GENERATED FILE. DO NOT MANUALLY EDIT!
|
2
|
+
# RUN : 'rake gem:update_gemspec'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.authors = ["Will Green", "David Blackmon", "Ivan Porto Carrero"]
|
6
|
+
s.bindir = "bin"
|
7
|
+
s.add_dependency "term-ansicolor", ">= 1.0.4"
|
8
|
+
s.description = "iron-term-ansicolor brings color output for RSpec and the likes to IronRuby."
|
9
|
+
s.email = "will@hotgazpacho.org"
|
10
|
+
s.extra_rdoc_files = ["README.rdoc"]
|
11
|
+
s.files = ["README.rdoc",
|
12
|
+
"Rakefile",
|
13
|
+
"iron-term-ansicolor.gemspec",
|
14
|
+
"lib/iron-term-ansicolor.rb",
|
15
|
+
"spec/iron-term-ansicolor_simple_background_spec.rb",
|
16
|
+
"spec/iron-term-ansicolor_simple_foreground_spec.rb",
|
17
|
+
"spec/spec_helper.rb"]
|
18
|
+
s.has_rdoc = true
|
19
|
+
s.homepage = "http://github.com/hotgazpacho/iron-term-ansicolor"
|
20
|
+
s.loaded = false
|
21
|
+
s.name = "iron-term-ansicolor"
|
22
|
+
s.platform = "ruby"
|
23
|
+
s.rdoc_options = ["--quiet", "--title", "iron-term-ansicolor brings color output for RSpec and the likes to IronRuby.", "--main", "README.rdoc", "--line-numbers", "--format", "darkfish"]
|
24
|
+
s.require_paths = ["lib"]
|
25
|
+
s.required_ruby_version = ">= 1.8.6"
|
26
|
+
s.required_rubygems_version = ">= 0"
|
27
|
+
s.rubyforge_project = "iron-term-ansicolor"
|
28
|
+
s.rubygems_version = "1.3.5"
|
29
|
+
s.specification_version = 3
|
30
|
+
s.summary = "iron-term-ansicolor brings color output for RSpec and the likes to IronRuby."
|
31
|
+
s.version = "0.0.1"
|
32
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'mscorlib'
|
2
|
+
require 'term/ansicolor'
|
3
|
+
|
4
|
+
## add the trailing m because some of the rspec output spans multiple lines
|
5
|
+
ANSI_REGEXP = /\e\[(.+?)m(.+?)(?=(\e\[0m|\z))/m
|
6
|
+
SsC=System::ConsoleColor
|
7
|
+
SC = System::Console
|
8
|
+
|
9
|
+
class String
|
10
|
+
include Term::ANSIColor
|
11
|
+
end
|
12
|
+
|
13
|
+
module IronTermAnsiColor
|
14
|
+
module Version
|
15
|
+
MAJOR=0
|
16
|
+
MINOR=0
|
17
|
+
PATCH=1
|
18
|
+
STRING="#{MAJOR}.#{MINOR}.#{PATCH}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class IO
|
23
|
+
alias_method :original_write, :write
|
24
|
+
alias_method :original_puts, :puts
|
25
|
+
|
26
|
+
def puts(*args)
|
27
|
+
rewrite(*args) { |text| original_puts text }
|
28
|
+
nil
|
29
|
+
end
|
30
|
+
|
31
|
+
def write(*args)
|
32
|
+
rewrite(*args) { |text| original_write text }
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
def extract_ansi_data(clr, txt)
|
37
|
+
fg_color_map = Hash[30,SsC.black,31,SsC.red,32,SsC.dark_green,33,SsC.dark_yellow,34,SsC.dark_blue,35,SsC.dark_magenta,
|
38
|
+
36,SsC.dark_cyan,37,SsC.gray]
|
39
|
+
bg_color_map = Hash[40,SsC.black,41,SsC.dark_red,42,SsC.dark_green,43,SsC.dark_yellow,44,SsC.dark_blue,45,SsC.dark_magenta,
|
40
|
+
46,SsC.dark_cyan,47,SsC.gray]
|
41
|
+
|
42
|
+
#matches = ANSI_REGEXP.match(arg)
|
43
|
+
|
44
|
+
fg_color = fg_color_map[clr] || SC.foreground_color
|
45
|
+
bg_color = bg_color_map[clr] || SC.background_color
|
46
|
+
|
47
|
+
{ :foreground => fg_color, :background => bg_color,:text => txt}
|
48
|
+
end
|
49
|
+
|
50
|
+
def rewrite(*args, &b)
|
51
|
+
raise ArgumentError, "needs a block" unless b
|
52
|
+
result=0
|
53
|
+
args.each do |arg|
|
54
|
+
fg_color = SC.foreground_color
|
55
|
+
bg_color = SC.background_color
|
56
|
+
|
57
|
+
##dkb
|
58
|
+
data = if ANSI_REGEXP =~ arg
|
59
|
+
extract_ansi_data($1.to_i, $2)
|
60
|
+
else
|
61
|
+
{:text => arg}
|
62
|
+
end
|
63
|
+
|
64
|
+
SC.foreground_color = data[:foreground] || fg_color
|
65
|
+
SC.background_color = data[:background] || bg_color
|
66
|
+
result = b.call data[:text]
|
67
|
+
SC.background_color = bg_color
|
68
|
+
SC.foreground_color = fg_color
|
69
|
+
end
|
70
|
+
result
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "IronTermANSIColor", "when given a string with ANSI background color control characters" do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
@original_bgcolor = System::ConsoleColor.Gray
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should set the background color to black when doing a puts of a string with only black background ANSI control code and reset the background color after" do
|
10
|
+
string = "Black".on_black
|
11
|
+
System::Console.should_receive(:background_color).at_least(:once).and_return(@original_bgcolor)
|
12
|
+
System::Console.should_receive(:background_color=).once.with(System::ConsoleColor.Black)
|
13
|
+
System::Console.should_receive(:background_color=).at_least(:once).with(@original_bgcolor)
|
14
|
+
puts string
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should set the background color to dark red when doing a puts of a string with only red background ANSI control code and reset the background color after" do
|
18
|
+
string = "Red".on_red
|
19
|
+
System::Console.should_receive(:background_color).at_least(:once).and_return(@original_bgcolor)
|
20
|
+
System::Console.should_receive(:background_color=).once.with(System::ConsoleColor.DarkRed)
|
21
|
+
System::Console.should_receive(:background_color=).at_least(:once).with(@original_bgcolor)
|
22
|
+
puts string
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should set the background color to dark green when doing a puts of a string with only green background ANSI control code and reset the background color after" do
|
26
|
+
string = "Green".on_green
|
27
|
+
System::Console.should_receive(:background_color).at_least(:once).and_return(@original_bgcolor)
|
28
|
+
System::Console.should_receive(:background_color=).once.with(System::ConsoleColor.DarkGreen)
|
29
|
+
System::Console.should_receive(:background_color=).at_least(:once).with(@original_bgcolor)
|
30
|
+
puts string
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should set the background color to dark yellow when doing a puts of a string with only yellow background ANSI control code and reset the background color after" do
|
34
|
+
string = "Yellow".on_yellow
|
35
|
+
System::Console.should_receive(:background_color).at_least(:once).and_return(@original_bgcolor)
|
36
|
+
System::Console.should_receive(:background_color=).once.with(System::ConsoleColor.DarkYellow)
|
37
|
+
System::Console.should_receive(:background_color=).at_least(:once).with(@original_bgcolor)
|
38
|
+
puts string
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should set the background color to dark blue when doing a puts of a string with only blue background ANSI control code and reset the background color after" do
|
42
|
+
string = "Blue".on_blue
|
43
|
+
System::Console.should_receive(:background_color).at_least(:once).and_return(@original_bgcolor)
|
44
|
+
System::Console.should_receive(:background_color=).once.with(System::ConsoleColor.DarkBlue)
|
45
|
+
System::Console.should_receive(:background_color=).at_least(:once).with(@original_bgcolor)
|
46
|
+
puts string
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should set the background color to dark magenta when doing a puts of a string with only magenta background ANSI control code and reset the background color after" do
|
50
|
+
string = "Magenta".on_magenta
|
51
|
+
System::Console.should_receive(:background_color).at_least(:once).and_return(@original_bgcolor)
|
52
|
+
System::Console.should_receive(:background_color=).once.with(System::ConsoleColor.DarkMagenta)
|
53
|
+
System::Console.should_receive(:background_color=).at_least(:once).with(@original_bgcolor)
|
54
|
+
puts string
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should set the background color to dark cyan when doing a puts of a string with only cyan background ANSI control code and reset the background color after" do
|
58
|
+
string = "Cyan".on_cyan
|
59
|
+
System::Console.should_receive(:background_color).at_least(:once).and_return(@original_bgcolor)
|
60
|
+
System::Console.should_receive(:background_color=).once.with(System::ConsoleColor.DarkCyan)
|
61
|
+
System::Console.should_receive(:background_color=).at_least(:once).with(@original_bgcolor)
|
62
|
+
puts string
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should set the background color to gray when doing a puts of a string with only white background ANSI control code and reset the background color after" do
|
66
|
+
string = "Gray".on_white
|
67
|
+
System::Console.should_receive(:background_color).at_least(:once).and_return(@original_bgcolor)
|
68
|
+
System::Console.should_receive(:background_color=).exactly(3).times.with(System::ConsoleColor.Gray)
|
69
|
+
System::Console.should_receive(:background_color=).at_least(:once).with(@original_bgcolor)
|
70
|
+
puts string
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "IronTermANSIColor", "when given a string with ANSI foreground color control characters" do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
@original_fgcolor = System::ConsoleColor.Gray
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should set the foreground color to black when doing a puts of a string with only blackforeground ANSI control code and reset the foreground color after" do
|
10
|
+
string = "Black".black
|
11
|
+
System::Console.should_receive(:foreground_color).twice.and_return(@original_fgcolor)
|
12
|
+
System::Console.should_receive(:foreground_color=).once.with(System::ConsoleColor.black)
|
13
|
+
System::Console.should_receive(:foreground_color=).at_least(3).times.with(@original_fgcolor)
|
14
|
+
puts string
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should set the foreground color to dark red when doing a puts of a string with only redforeground ANSI control code and reset the foreground color after" do
|
18
|
+
string = "Red".red
|
19
|
+
System::Console.should_receive(:foreground_color).at_least(:once).and_return(@original_fgcolor)
|
20
|
+
System::Console.should_receive(:foreground_color=).once.with(System::ConsoleColor.red)
|
21
|
+
System::Console.should_receive(:foreground_color=).at_least(:once).with(@original_fgcolor)
|
22
|
+
puts string
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should set the foreground color to dark green when doing a puts of a string with only greenforeground ANSI control code and reset the foreground color after" do
|
26
|
+
string = "Green".green
|
27
|
+
System::Console.should_receive(:foreground_color).at_least(:once).and_return(@original_fgcolor)
|
28
|
+
System::Console.should_receive(:foreground_color=).once.with(System::ConsoleColor.dark_green)
|
29
|
+
System::Console.should_receive(:foreground_color=).at_least(:once).with(@original_fgcolor)
|
30
|
+
puts string
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should set the foreground color to dark yellow when doing a puts of a string with only yellowforeground ANSI control code and reset the foreground color after" do
|
34
|
+
string = "Yellow".yellow
|
35
|
+
System::Console.should_receive(:foreground_color).at_least(:once).and_return(@original_fgcolor)
|
36
|
+
System::Console.should_receive(:foreground_color=).once.with(System::ConsoleColor.DarkYellow)
|
37
|
+
System::Console.should_receive(:foreground_color=).at_least(:once).with(@original_fgcolor)
|
38
|
+
puts string
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should set the foreground color to dark blue when doing a puts of a string with only blueforeground ANSI control code and reset the foreground color after" do
|
42
|
+
string = "Blue".blue
|
43
|
+
System::Console.should_receive(:foreground_color).at_least(:once).and_return(@original_fgcolor)
|
44
|
+
System::Console.should_receive(:foreground_color=).once.with(System::ConsoleColor.DarkBlue)
|
45
|
+
System::Console.should_receive(:foreground_color=).at_least(:once).with(@original_fgcolor)
|
46
|
+
puts string
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should set the foreground color to dark magenta when doing a puts of a string with only magentaforeground ANSI control code and reset the foreground color after" do
|
50
|
+
string = "Magenta".magenta
|
51
|
+
System::Console.should_receive(:foreground_color).at_least(:once).and_return(@original_fgcolor)
|
52
|
+
System::Console.should_receive(:foreground_color=).at_least(:once).with(System::ConsoleColor.DarkMagenta)
|
53
|
+
System::Console.should_receive(:foreground_color=).at_least(:once).with(@original_fgcolor)
|
54
|
+
puts string
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should set the foreground color to dark cyan when doing a puts of a string with only cyanforeground ANSI control code and reset the foreground color after" do
|
58
|
+
string = "Cyan".cyan
|
59
|
+
System::Console.should_receive(:foreground_color).at_least(:once).and_return(@original_fgcolor)
|
60
|
+
System::Console.should_receive(:foreground_color=).once.with(System::ConsoleColor.DarkCyan)
|
61
|
+
System::Console.should_receive(:foreground_color=).at_least(:once).with(@original_fgcolor)
|
62
|
+
puts string
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should set the foreground color to gray when doing a puts of a string with only whiteforeground ANSI control code and reset the foreground color after" do
|
66
|
+
string = "Gray".white
|
67
|
+
System::Console.should_receive(:foreground_color).at_least(:once).and_return(@original_fgcolor)
|
68
|
+
System::Console.should_receive(:foreground_color=).at_least(:once).with(System::ConsoleColor.Gray)
|
69
|
+
System::Console.should_receive(:foreground_color=).at_least(:once).with(@original_fgcolor)
|
70
|
+
puts string
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: iron-term-ansicolor
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Will Green
|
8
|
+
- David Blackmon
|
9
|
+
- Ivan Porto Carrero
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2009-10-30 00:00:00 -04:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: term-ansicolor
|
18
|
+
type: :runtime
|
19
|
+
version_requirement:
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - '>='
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 1.0.4
|
25
|
+
version:
|
26
|
+
description: iron-term-ansicolor brings color output for RSpec and the likes to IronRuby.
|
27
|
+
email: will@hotgazpacho.org
|
28
|
+
executables: []
|
29
|
+
extensions: []
|
30
|
+
extra_rdoc_files:
|
31
|
+
- README.rdoc
|
32
|
+
files:
|
33
|
+
- README.rdoc
|
34
|
+
- Rakefile
|
35
|
+
- iron-term-ansicolor.gemspec
|
36
|
+
- lib/iron-term-ansicolor.rb
|
37
|
+
- spec/iron-term-ansicolor_simple_background_spec.rb
|
38
|
+
- spec/iron-term-ansicolor_simple_foreground_spec.rb
|
39
|
+
- spec/spec_helper.rb
|
40
|
+
has_rdoc: true
|
41
|
+
homepage: http://github.com/hotgazpacho/iron-term-ansicolor
|
42
|
+
licenses: []
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options:
|
45
|
+
- --quiet
|
46
|
+
- --title
|
47
|
+
- iron-term-ansicolor brings color output for RSpec and the likes to IronRuby.
|
48
|
+
- --main
|
49
|
+
- README.rdoc
|
50
|
+
- --line-numbers
|
51
|
+
- --format
|
52
|
+
- darkfish
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 1.8.6
|
60
|
+
version:
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: !str 0
|
66
|
+
version:
|
67
|
+
requirements: []
|
68
|
+
rubyforge_project: iron-term-ansicolor
|
69
|
+
rubygems_version: 1.3.5
|
70
|
+
signing_key:
|
71
|
+
specification_version: 3
|
72
|
+
summary: iron-term-ansicolor brings color output for RSpec and the likes to IronRuby.
|
73
|
+
test_files: []
|