Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

removed 'ruby -w' warnings', version bump, more tests

  • Loading branch information...
commit 47728fa63b5f83aca51da8257a41eb35786a2c63 1 parent 78e3c73
@fazibear authored
View
6 CHANGELOG.rdoc
@@ -1,4 +1,8 @@
-== 0.5.7 / 2000-11-24
+== 0.5.8 / 2009-12-02
+ * code cleanups
+ * removed 'ruby -w' warnings
+
+== 0.5.7 / 2009-11-24
* moved to github/gemcutter
* 1.9 compatibile
View
2  VERSION
@@ -1 +1 @@
-0.5.7
+0.5.8
View
4 colorize.gemspec
@@ -5,11 +5,11 @@
Gem::Specification.new do |s|
s.name = %q{colorize}
- s.version = "0.5.7"
+ s.version = "0.5.8"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["fazibear"]
- s.date = %q{2009-11-24}
+ s.date = %q{2009-12-02}
s.description = %q{Ruby string class extension. It add some methods to set color, background color and text effect on console easier. Uses ANSI escape sequences.}
s.email = %q{fazibear@gmail.com}
s.extra_rdoc_files = [
View
18 lib/colorize.rb
@@ -55,7 +55,7 @@ def set_color_parameters( params )
nil
end
end
-
+
public
#
@@ -93,11 +93,11 @@ def colorize( params )
color_parameters[:color] = COLORS[params]
end
- color_parameters[:color] ||= @color || 9
- color_parameters[:background] ||= @background || 9
- color_parameters[:mode] ||= @mode || 0
+ color_parameters[:color] ||= @color ||= COLORS[:default]
+ color_parameters[:background] ||= @background ||= COLORS[:default]
+ color_parameters[:mode] ||= @mode ||= MODES[:default]
- color_parameters[:uncolorized] ||= @uncolorized || self.dup
+ color_parameters[:uncolorized] ||= @uncolorized ||= self.dup
# calculate bright mode
color_parameters[:color] += 50 if color_parameters[:color] > 10
@@ -118,13 +118,15 @@ def uncolorize
# Return true if sting is colorized
#
def colorized?
- !@uncolorized.nil?
+ !defined?(@uncolorized).nil?
end
#
# Make some color and on_color methods
#
COLORS.each_key do | key |
+ next if key == :default
+
define_method key do
self.colorize( :color => key )
end
@@ -138,6 +140,8 @@ def colorized?
# Methods for modes
#
MODES.each_key do | key |
+ next if key == :default
+
define_method key do
self.colorize( :mode => key )
end
@@ -181,7 +185,7 @@ def color_matrix( txt = "[X]" )
String.colors.reverse.each_with_index do | back, index |
puts "#{"|".rjust(txt.length)*(size-index)} < #{back}"
end
+ ""
end
end
- puts
end
View
6 test/test_colorize.rb
@@ -40,4 +40,10 @@ def test_blue_with_red_background_and_blink_methods
def test_uncolorize
assert "This is uncolorized".blue.on_red.uncolorize == "This is uncolorized"
end
+
+ def test_colorized?
+ assert "Red".red.colorized? == true
+ assert "Blue".colorized? == false
+ assert "Green".blue.green.uncolorize.colorized? == false
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.