rainbow 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.markdown +34 -0
  2. data/lib/rainbow.rb +3 -3
  3. metadata +7 -5
  4. data/README +0 -11
@@ -0,0 +1,34 @@
1
+ Rainbow
2
+ =======
3
+
4
+ About
5
+ -----
6
+
7
+ Rainbow extends ruby String class adding methods to wrap the string with "ANSI escape codes":http://en.wikipedia.org/wiki/ANSI_escape_code.
8
+
9
+ Features
10
+ --------
11
+
12
+ Rainbow adds following methods to String class:
13
+
14
+ * foreground(color) (with _color_ and _colour_ aliases)
15
+ * background(color)
16
+ * reset
17
+ * bright
18
+ * italic (not well supported by terminal emulators).
19
+ * underline
20
+ * blink
21
+ * inverse
22
+ * hide.
23
+
24
+ Color can be one of following symbols: :black, :red, :green, :yellow, :blue, :magenta, :cyan, :white and :default.
25
+
26
+ Each of those methods returns string wrapped with some ANSI codes so you can chain calls as in example above.
27
+
28
+ It also has Windows support (uses win32console gem if installed, otherwise strings are returned unaltered).
29
+
30
+ Usage
31
+ -----
32
+
33
+ require 'rainbow'
34
+ puts "this is red".foreground(:red) + " and " + "this on yellow bg".background(:yellow) + " and " + "even bright underlined!".underline.bright
@@ -24,11 +24,11 @@ module Sickill
24
24
  }
25
25
 
26
26
  # Sets foreground color if this text.
27
- def foreground(color)
27
+ def foreground(color)
28
28
  color = color.to_sym
29
29
  validate_color(color)
30
30
  wrap_with_code(TERM_COLORS[color] + 30)
31
- end
31
+ end
32
32
  alias_method :color, :foreground
33
33
  alias_method :colour, :foreground
34
34
 
@@ -79,7 +79,7 @@ module Sickill
79
79
 
80
80
  protected
81
81
  def wrap_with_code(code) #:nodoc:
82
- out = self
82
+ out = "#{self}"
83
83
  match = out.match(/^(\e\[([\d;]+)m)*/)
84
84
  out.insert(match.end(0), "\e[#{code}m")
85
85
  out.concat("\e[0m") unless out =~ /\e\[0m$/
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rainbow
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcin Kulik
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-16 00:00:00 +02:00
12
+ date: 2009-07-26 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -22,13 +22,15 @@ extensions: []
22
22
  extra_rdoc_files: []
23
23
 
24
24
  files:
25
- - README
25
+ - README.markdown
26
26
  - Changelog
27
27
  - LICENSE
28
28
  - lib/rainbow.rb
29
29
  - test/rainbow_test.rb
30
30
  has_rdoc: true
31
31
  homepage: http://sickill.net
32
+ licenses: []
33
+
32
34
  post_install_message:
33
35
  rdoc_options: []
34
36
 
@@ -49,9 +51,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
51
  requirements: []
50
52
 
51
53
  rubyforge_project: rainbow
52
- rubygems_version: 1.3.1
54
+ rubygems_version: 1.3.3
53
55
  signing_key:
54
- specification_version: 2
56
+ specification_version: 3
55
57
  summary: Rainbow extends ruby String class enabling coloring text on ANSI terminals
56
58
  test_files: []
57
59
 
data/README DELETED
@@ -1,11 +0,0 @@
1
- == Rainbow
2
-
3
- === About
4
-
5
- It's!
6
-
7
- === Usage
8
-
9
- require 'rainbow'
10
- puts "this is red".foreground(:red)
11
-