rainbow 1.0.4 → 1.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.markdown +16 -2
- data/lib/rainbow.rb +7 -9
- metadata +11 -5
data/README.markdown
CHANGED
@@ -21,14 +21,28 @@ Rainbow adds following methods to String class:
|
|
21
21
|
* inverse
|
22
22
|
* hide.
|
23
23
|
|
24
|
-
Color can be one of following symbols: :black, :red, :green, :yellow, :blue, :magenta, :cyan, :white and :default.
|
25
|
-
|
26
24
|
Each of those methods returns string wrapped with some ANSI codes so you can chain calls as in example above.
|
27
25
|
|
26
|
+
Color can be one of following symbols:
|
27
|
+
|
28
|
+
:black, :red, :green, :yellow, :blue, :magenta, :cyan, :white, :default
|
29
|
+
|
30
|
+
If you have 256-colors capable terminal you can also specify color in RGB which will find the nearest match from 256 colors palette:
|
31
|
+
|
32
|
+
"Jolacz".color(115, 23, 98)
|
33
|
+
"Jolacz".color("#FFC482")
|
34
|
+
"Jolacz".color("FFC482")
|
35
|
+
|
28
36
|
It also has Windows support (uses win32console gem if installed, otherwise strings are returned unaltered).
|
29
37
|
|
38
|
+
Installation
|
39
|
+
------------
|
40
|
+
|
41
|
+
gem install rainbow -s http://gemcutter.org
|
42
|
+
|
30
43
|
Usage
|
31
44
|
-----
|
32
45
|
|
33
46
|
require 'rainbow'
|
34
47
|
puts "this is red".foreground(:red) + " and " + "this on yellow bg".background(:yellow) + " and " + "even bright underlined!".underline.bright
|
48
|
+
|
data/lib/rainbow.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Sickill
|
2
2
|
module Rainbow
|
3
|
+
class << self; attr_accessor :enabled; end
|
4
|
+
@enabled = STDOUT.tty? && ENV['TERM'] != 'dumb'
|
3
5
|
|
4
6
|
TERM_COLORS = {
|
5
7
|
:black => 0,
|
@@ -77,6 +79,8 @@ module Sickill
|
|
77
79
|
|
78
80
|
protected
|
79
81
|
def wrap_with_code(code) #:nodoc:
|
82
|
+
return self unless Sickill::Rainbow.enabled
|
83
|
+
|
80
84
|
out = "#{self}"
|
81
85
|
match = out.match(/^(\e\[([\d;]+)m)*/)
|
82
86
|
out.insert(match.end(0), "\e[#{code}m")
|
@@ -112,16 +116,10 @@ module Sickill
|
|
112
116
|
end
|
113
117
|
end
|
114
118
|
|
119
|
+
String.send(:include, Sickill::Rainbow)
|
120
|
+
|
115
121
|
begin
|
116
122
|
require 'Win32/Console/ANSI' if RUBY_PLATFORM =~ /win32/
|
117
123
|
rescue LoadError
|
118
|
-
|
119
|
-
module Sickill::Rainbow
|
120
|
-
protected
|
121
|
-
def wrap_with_code(code)
|
122
|
-
self
|
123
|
-
end
|
124
|
-
end
|
124
|
+
Sickill::Rainbow.enabled = false
|
125
125
|
end
|
126
|
-
|
127
|
-
String.send(:include, Sickill::Rainbow)
|
metadata
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rainbow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 1
|
8
|
+
version: "1.1"
|
5
9
|
platform: ruby
|
6
10
|
authors:
|
7
11
|
- Marcin Kulik
|
@@ -9,7 +13,7 @@ autorequire:
|
|
9
13
|
bindir: bin
|
10
14
|
cert_chain: []
|
11
15
|
|
12
|
-
date:
|
16
|
+
date: 2010-06-07 00:00:00 +02:00
|
13
17
|
default_executable:
|
14
18
|
dependencies: []
|
15
19
|
|
@@ -40,18 +44,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
40
44
|
requirements:
|
41
45
|
- - ">="
|
42
46
|
- !ruby/object:Gem::Version
|
47
|
+
segments:
|
48
|
+
- 0
|
43
49
|
version: "0"
|
44
|
-
version:
|
45
50
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
51
|
requirements:
|
47
52
|
- - ">="
|
48
53
|
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 0
|
49
56
|
version: "0"
|
50
|
-
version:
|
51
57
|
requirements: []
|
52
58
|
|
53
59
|
rubyforge_project:
|
54
|
-
rubygems_version: 1.3.
|
60
|
+
rubygems_version: 1.3.6
|
55
61
|
signing_key:
|
56
62
|
specification_version: 3
|
57
63
|
summary: Rainbow extends ruby String class enabling coloring text on ANSI terminals
|