Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit 47728fa63b5f83aca51da8257a41eb35786a2c63 1 parent 78e3c73
fazibear authored
6 CHANGELOG.rdoc
Source Rendered
... ... @@ -1,4 +1,8 @@
1   -== 0.5.7 / 2000-11-24
  1 +== 0.5.8 / 2009-12-02
  2 + * code cleanups
  3 + * removed 'ruby -w' warnings
  4 +
  5 +== 0.5.7 / 2009-11-24
2 6 * moved to github/gemcutter
3 7 * 1.9 compatibile
4 8
2  VERSION
... ... @@ -1 +1 @@
1   -0.5.7
  1 +0.5.8
4 colorize.gemspec
@@ -5,11 +5,11 @@
5 5
6 6 Gem::Specification.new do |s|
7 7 s.name = %q{colorize}
8   - s.version = "0.5.7"
  8 + s.version = "0.5.8"
9 9
10 10 s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11 11 s.authors = ["fazibear"]
12   - s.date = %q{2009-11-24}
  12 + s.date = %q{2009-12-02}
13 13 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.}
14 14 s.email = %q{fazibear@gmail.com}
15 15 s.extra_rdoc_files = [
18 lib/colorize.rb
@@ -55,7 +55,7 @@ def set_color_parameters( params )
55 55 nil
56 56 end
57 57 end
58   -
  58 +
59 59 public
60 60
61 61 #
@@ -93,11 +93,11 @@ def colorize( params )
93 93 color_parameters[:color] = COLORS[params]
94 94 end
95 95
96   - color_parameters[:color] ||= @color || 9
97   - color_parameters[:background] ||= @background || 9
98   - color_parameters[:mode] ||= @mode || 0
  96 + color_parameters[:color] ||= @color ||= COLORS[:default]
  97 + color_parameters[:background] ||= @background ||= COLORS[:default]
  98 + color_parameters[:mode] ||= @mode ||= MODES[:default]
99 99
100   - color_parameters[:uncolorized] ||= @uncolorized || self.dup
  100 + color_parameters[:uncolorized] ||= @uncolorized ||= self.dup
101 101
102 102 # calculate bright mode
103 103 color_parameters[:color] += 50 if color_parameters[:color] > 10
@@ -118,13 +118,15 @@ def uncolorize
118 118 # Return true if sting is colorized
119 119 #
120 120 def colorized?
121   - !@uncolorized.nil?
  121 + !defined?(@uncolorized).nil?
122 122 end
123 123
124 124 #
125 125 # Make some color and on_color methods
126 126 #
127 127 COLORS.each_key do | key |
  128 + next if key == :default
  129 +
128 130 define_method key do
129 131 self.colorize( :color => key )
130 132 end
@@ -138,6 +140,8 @@ def colorized?
138 140 # Methods for modes
139 141 #
140 142 MODES.each_key do | key |
  143 + next if key == :default
  144 +
141 145 define_method key do
142 146 self.colorize( :mode => key )
143 147 end
@@ -181,7 +185,7 @@ def color_matrix( txt = "[X]" )
181 185 String.colors.reverse.each_with_index do | back, index |
182 186 puts "#{"|".rjust(txt.length)*(size-index)} < #{back}"
183 187 end
  188 + ""
184 189 end
185 190 end
186   - puts
187 191 end
6 test/test_colorize.rb
@@ -40,4 +40,10 @@ def test_blue_with_red_background_and_blink_methods
40 40 def test_uncolorize
41 41 assert "This is uncolorized".blue.on_red.uncolorize == "This is uncolorized"
42 42 end
  43 +
  44 + def test_colorized?
  45 + assert "Red".red.colorized? == true
  46 + assert "Blue".colorized? == false
  47 + assert "Green".blue.green.uncolorize.colorized? == false
  48 + end
43 49 end

0 comments on commit 47728fa

Please sign in to comment.
Something went wrong with that request. Please try again.