rainbow 1.1 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.markdown +21 -3
  2. data/lib/rainbow.rb +9 -4
  3. metadata +6 -3
data/README.markdown CHANGED
@@ -4,7 +4,7 @@ Rainbow
4
4
  About
5
5
  -----
6
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.
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
8
 
9
9
  Features
10
10
  --------
@@ -33,12 +33,22 @@ If you have 256-colors capable terminal you can also specify color in RGB which
33
33
  "Jolacz".color("#FFC482")
34
34
  "Jolacz".color("FFC482")
35
35
 
36
- It also has Windows support (uses win32console gem if installed, otherwise strings are returned unaltered).
36
+ For support on Windows, you should install the following gems:
37
+
38
+ gem install windows-pr win32console
39
+
40
+ If the gems aren't installed strings are simply returned unaltered.
41
+
42
+ Rainbow can be disabled globally by setting:
43
+
44
+ Sickill::Rainbow.enabled = false
45
+
46
+ It will be disabled by default if it detects that STDOUT is not a TTY.
37
47
 
38
48
  Installation
39
49
  ------------
40
50
 
41
- gem install rainbow -s http://gemcutter.org
51
+ gem install rainbow
42
52
 
43
53
  Usage
44
54
  -----
@@ -46,3 +56,11 @@ Usage
46
56
  require 'rainbow'
47
57
  puts "this is red".foreground(:red) + " and " + "this on yellow bg".background(:yellow) + " and " + "even bright underlined!".underline.bright
48
58
 
59
+ Rails Usage
60
+ -----------
61
+
62
+ You're probably wanting to add colour to your logs. To do so you must explicity enable rainbow because it will detect that STDOUT (ie: the log file) is not a TTY.
63
+ To make things easy, create the file `config/initializers/rainbow.rb` and include the following:
64
+
65
+ require 'rainbow'
66
+ Sickill::Rainbow.enabled = true
data/lib/rainbow.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'rbconfig'
2
+
1
3
  module Sickill
2
4
  module Rainbow
3
5
  class << self; attr_accessor :enabled; end
@@ -118,8 +120,11 @@ end
118
120
 
119
121
  String.send(:include, Sickill::Rainbow)
120
122
 
121
- begin
122
- require 'Win32/Console/ANSI' if RUBY_PLATFORM =~ /win32/
123
- rescue LoadError
124
- Sickill::Rainbow.enabled = false
123
+ # On Windows systems, try to load the local ANSI support library
124
+ if Config::CONFIG['host_os'] =~ /mswin|mingw/
125
+ begin
126
+ require 'Win32/Console/ANSI'
127
+ rescue LoadError
128
+ Sickill::Rainbow.enabled = false
129
+ end
125
130
  end
metadata CHANGED
@@ -5,7 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 1
8
- version: "1.1"
8
+ - 1
9
+ version: 1.1.1
9
10
  platform: ruby
10
11
  authors:
11
12
  - Marcin Kulik
@@ -13,7 +14,7 @@ autorequire:
13
14
  bindir: bin
14
15
  cert_chain: []
15
16
 
16
- date: 2010-06-07 00:00:00 +02:00
17
+ date: 2011-02-06 00:00:00 +01:00
17
18
  default_executable:
18
19
  dependencies: []
19
20
 
@@ -41,6 +42,7 @@ rdoc_options: []
41
42
  require_paths:
42
43
  - lib
43
44
  required_ruby_version: !ruby/object:Gem::Requirement
45
+ none: false
44
46
  requirements:
45
47
  - - ">="
46
48
  - !ruby/object:Gem::Version
@@ -48,6 +50,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
48
50
  - 0
49
51
  version: "0"
50
52
  required_rubygems_version: !ruby/object:Gem::Requirement
53
+ none: false
51
54
  requirements:
52
55
  - - ">="
53
56
  - !ruby/object:Gem::Version
@@ -57,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
60
  requirements: []
58
61
 
59
62
  rubyforge_project:
60
- rubygems_version: 1.3.6
63
+ rubygems_version: 1.3.7
61
64
  signing_key:
62
65
  specification_version: 3
63
66
  summary: Rainbow extends ruby String class enabling coloring text on ANSI terminals