colorblind 1.0.0

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.
@@ -0,0 +1,11 @@
1
+ # .document is used by rdoc and yard to know how to generate documentation
2
+ # for example, it can be used to control how rdoc gets built when you do `gem install foo`
3
+
4
+ README.rdoc
5
+ lib/**/*.rb
6
+ bin/*
7
+
8
+ # Files below this - are treated as 'extra files', and aren't parsed for ruby code
9
+ -
10
+ features/**/*.feature
11
+ LICENSE
@@ -0,0 +1,42 @@
1
+ # rcov generated
2
+ coverage
3
+
4
+ # rdoc generated
5
+ rdoc
6
+
7
+ # yard generated
8
+ doc
9
+ .yardoc
10
+
11
+ # bundler
12
+ .bundle
13
+
14
+ # jeweler generated
15
+ pkg
16
+
17
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
18
+ #
19
+ # * Create a file at ~/.gitignore
20
+ # * Include files you want ignored
21
+ # * Run: git config --global core.excludesfile ~/.gitignore
22
+ #
23
+ # After doing this, these files will be ignored in all your git projects,
24
+ # saving you from having to 'pollute' every project you touch with them
25
+ #
26
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
27
+ #
28
+ # For MacOS:
29
+ #
30
+ #.DS_Store
31
+ #
32
+ # For TextMate
33
+ #*.tmproj
34
+ #tmtags
35
+ #
36
+ # For emacs:
37
+ #*~
38
+ #\#*
39
+ #.\#*
40
+ #
41
+ # For vim:
42
+ #*.swp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm --create use ruby-1.8.7@colorblind > /dev/null
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ gem "activesupport", "= 3.0.0"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "rspec", ">= 2.0.0.beta.22"
10
+ gem "bundler", "~> 1.0.0"
11
+ gem "jeweler", "~> 1.5.0.pre3"
12
+ end
@@ -0,0 +1,30 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activesupport (3.0.0)
5
+ diff-lcs (1.1.2)
6
+ git (1.2.5)
7
+ jeweler (1.5.0.pre3)
8
+ bundler (~> 1.0.0)
9
+ git (>= 1.2.5)
10
+ rake
11
+ rake (0.8.7)
12
+ rspec (2.0.0.beta.22)
13
+ rspec-core (= 2.0.0.beta.22)
14
+ rspec-expectations (= 2.0.0.beta.22)
15
+ rspec-mocks (= 2.0.0.beta.22)
16
+ rspec-core (2.0.0.beta.22)
17
+ rspec-expectations (2.0.0.beta.22)
18
+ diff-lcs (>= 1.1.2)
19
+ rspec-mocks (2.0.0.beta.22)
20
+ rspec-core (= 2.0.0.beta.22)
21
+ rspec-expectations (= 2.0.0.beta.22)
22
+
23
+ PLATFORMS
24
+ ruby
25
+
26
+ DEPENDENCIES
27
+ activesupport (= 3.0.0)
28
+ bundler (~> 1.0.0)
29
+ jeweler (~> 1.5.0.pre3)
30
+ rspec (>= 2.0.0.beta.22)
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Josep M. Bach
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,61 @@
1
+ = colorblind
2
+
3
+ Colorblind is a Rails 3 gem that extends your ActiveSupport logger with trendy colorschemes from the 90's.
4
+
5
+ You thought 90's were over? Then why are you still using your terminal as if you still had that old 2-color 14-inch 40-kg display?
6
+
7
+ == Usage
8
+
9
+ Just use your logger as you would (in your models or controllers, for example, through the logger method) BUT take a look at the spicy syntax:
10
+
11
+ logger.debug "I really <blue>think</> that <RED>#{suspicious_object.strange_method}</> is not returning what <magenta>my boss</> would want to."
12
+ logger.warn "Called a <green>really good</> method which may <GREEN>delete your hard drive</> :)"
13
+
14
+ And hide your logs so that your magenta boss won't find out!
15
+
16
+ == Cheatsheet
17
+
18
+ These are the color codes: basically, downcase for text colors and upcase for background colors!
19
+
20
+ <black> text </>
21
+ <red> text </>
22
+ <green> text </>
23
+ <yellow> text </>
24
+ <blue> text </>
25
+ <magenta> text </>
26
+ <cyan> text </>
27
+ <white> text </>
28
+
29
+ <RED> backgrounded text </>
30
+ <GREEN> backgrounded text </>
31
+ <YELLOW> backgrounded text </>
32
+ <BLUE> backgrounded text </>
33
+ <MAGENtA> backgrounded text </>
34
+ <CYAN> backgrounded text </>
35
+ <WHITE> backgrounded text </>
36
+
37
+ == Install
38
+
39
+ Just put this in your Gemfile:
40
+
41
+ gem "colorblind"
42
+
43
+ And ta-da!
44
+
45
+ == TODO
46
+
47
+ * Add support for bold and underline modifiers
48
+
49
+ == Note on Patches/Pull Requests
50
+
51
+ * Fork the project.
52
+ * Make your feature addition or bug fix.
53
+ * Add tests for it. This is important so I don't break it in a
54
+ future version unintentionally.
55
+ * Commit, do not mess with rakefile, version, or history.
56
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
57
+ * Send me a pull request. Bonus points for topic branches.
58
+
59
+ == Copyright
60
+
61
+ Copyright (c) 2010 Codegram. See LICENSE for details.
@@ -0,0 +1,37 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "colorblind"
16
+ gem.summary = %Q{Colorblind extends ActiveSupport logger with trendy colorschemes from the 90's!}
17
+ gem.description = %Q{Colorblind extends ActiveSupport logger with trendy colorschemes from the 90's!}
18
+ gem.email = "info@codegram.com"
19
+ gem.homepage = "http://github.com/codegram/colorblind"
20
+ gem.authors = ["Oriol Gual", "Josep M. Bach", "Josep Jaume Rey"]
21
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
22
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
23
+ gem.add_runtime_dependency "activesupport", "= 3.0.0"
24
+
25
+ gem.add_development_dependency "rspec", ">= 2.0.0.beta.22"
26
+ gem.add_development_dependency "bundler", "~> 1.0.0"
27
+ gem.add_development_dependency "jeweler", "~> 1.5.0.pre3"
28
+ end
29
+ Jeweler::RubygemsDotOrgTasks.new
30
+
31
+ require 'rspec/core'
32
+ require 'rspec/core/rake_task'
33
+ RSpec::Core::RakeTask.new(:spec) do |spec|
34
+ spec.pattern = FileList['spec/**/*_spec.rb']
35
+ end
36
+
37
+ task :default => :spec
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
@@ -0,0 +1,78 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{colorblind}
8
+ s.version = "1.0.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Oriol Gual", "Josep M. Bach", "Josep Jaume Rey"]
12
+ s.date = %q{2010-09-15}
13
+ s.description = %q{Colorblind extends ActiveSupport logger with trendy colorschemes from the 90's!}
14
+ s.email = %q{info@codegram.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ ".rspec",
23
+ ".rvmrc",
24
+ "Gemfile",
25
+ "Gemfile.lock",
26
+ "LICENSE",
27
+ "README.rdoc",
28
+ "Rakefile",
29
+ "VERSION",
30
+ "colorblind.gemspec",
31
+ "lib/colorblind.rb",
32
+ "spec/colorblind_spec.rb",
33
+ "spec/spec_helper.rb"
34
+ ]
35
+ s.homepage = %q{http://github.com/codegram/colorblind}
36
+ s.require_paths = ["lib"]
37
+ s.rubygems_version = %q{1.3.7}
38
+ s.summary = %q{Colorblind extends ActiveSupport logger with trendy colorschemes from the 90's!}
39
+ s.test_files = [
40
+ "spec/colorblind_spec.rb",
41
+ "spec/spec_helper.rb"
42
+ ]
43
+
44
+ if s.respond_to? :specification_version then
45
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
46
+ s.specification_version = 3
47
+
48
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
+ s.add_runtime_dependency(%q<activesupport>, ["= 3.0.0"])
50
+ s.add_development_dependency(%q<rspec>, [">= 2.0.0.beta.22"])
51
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
52
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.0.pre3"])
53
+ s.add_runtime_dependency(%q<activesupport>, ["= 3.0.0"])
54
+ s.add_development_dependency(%q<rspec>, [">= 2.0.0.beta.22"])
55
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
56
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.0.pre3"])
57
+ else
58
+ s.add_dependency(%q<activesupport>, ["= 3.0.0"])
59
+ s.add_dependency(%q<rspec>, [">= 2.0.0.beta.22"])
60
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
61
+ s.add_dependency(%q<jeweler>, ["~> 1.5.0.pre3"])
62
+ s.add_dependency(%q<activesupport>, ["= 3.0.0"])
63
+ s.add_dependency(%q<rspec>, [">= 2.0.0.beta.22"])
64
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
65
+ s.add_dependency(%q<jeweler>, ["~> 1.5.0.pre3"])
66
+ end
67
+ else
68
+ s.add_dependency(%q<activesupport>, ["= 3.0.0"])
69
+ s.add_dependency(%q<rspec>, [">= 2.0.0.beta.22"])
70
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
71
+ s.add_dependency(%q<jeweler>, ["~> 1.5.0.pre3"])
72
+ s.add_dependency(%q<activesupport>, ["= 3.0.0"])
73
+ s.add_dependency(%q<rspec>, [">= 2.0.0.beta.22"])
74
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
75
+ s.add_dependency(%q<jeweler>, ["~> 1.5.0.pre3"])
76
+ end
77
+ end
78
+
@@ -0,0 +1,52 @@
1
+ require 'active_support/core_ext/module' # For alias_method_chain
2
+ require 'active_support/buffered_logger'
3
+
4
+ module Colorblind
5
+
6
+ def self.included(base)
7
+ base.class_eval do
8
+ include InstanceMethods
9
+ alias_method_chain :add, :colors
10
+ end
11
+ end
12
+
13
+ module InstanceMethods
14
+
15
+ def add_with_colors(severity, message = nil, progname = nil, &block)
16
+ message.gsub!(/(<[a-zA-Z]+>)/) {|color| color_to_code(color)}
17
+ message.gsub!('</>', "\e[0m")
18
+ add_without_colors(severity, message, progname, &block)
19
+ end
20
+
21
+ private
22
+
23
+ def color_to_code(color)
24
+ color = case color.gsub(/<?>?/,'')
25
+ when "black" then "30"
26
+ when "red" then "31"
27
+ when "green" then "32"
28
+ when "yellow" then "33"
29
+ when "blue" then "34"
30
+ when "magenta" then "35"
31
+ when "cyan" then "36"
32
+ when "white" then "37"
33
+
34
+ when "RED" then "41"
35
+ when "GREEN" then "42"
36
+ when "YELLOW" then "43"
37
+ when "BLUE" then "44"
38
+ when "MAGENTA" then "45"
39
+ when "CYAN" then "46"
40
+ when "WHITE" then "47"
41
+ end
42
+ "\e[0;#{color}m"
43
+ end
44
+ end
45
+
46
+ end
47
+
48
+ module ActiveSupport
49
+ class BufferedLogger
50
+ include Colorblind
51
+ end
52
+ end
@@ -0,0 +1,39 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Colorblind-enhanced logger" do
4
+
5
+ before(:each) do
6
+ @output = StringIO.new
7
+ @logger = ActiveSupport::BufferedLogger.new(@output)
8
+ end
9
+
10
+ it "is Colorblind-enhanced" do
11
+ @logger.should respond_to(:add_with_colors)
12
+ end
13
+
14
+ it "converts pseudo-xml tags to colors" do
15
+ colors =
16
+ {"black" => "30",
17
+ "red" => "31",
18
+ "green" => "32",
19
+ "yellow" => "33",
20
+ "blue" => "34",
21
+ "magenta" => "35",
22
+ "cyan" => "36",
23
+ "white" => "37",
24
+
25
+ "RED" => "41",
26
+ "GREEN" => "42",
27
+ "YELLOW" => "43",
28
+ "BLUE" => "44",
29
+ "MAGENTA" => "45",
30
+ "CYAN" => "46",
31
+ "WHITE" => "47"}
32
+
33
+ colors.each_pair do |color,code|
34
+ @logger.debug "I have a nice <#{color}>color</> and I like it"
35
+ @output.string.should include("I have a nice \e[0;#{code}mcolor\e[0m and I like it")
36
+ end
37
+ end
38
+
39
+ end
@@ -0,0 +1,21 @@
1
+ require 'bundler'
2
+ begin
3
+ Bundler.setup(:default, :development)
4
+ rescue Bundler::BundlerError => e
5
+ $stderr.puts e.message
6
+ $stderr.puts "Run `bundle install` to install missing gems"
7
+ exit e.status_code
8
+ end
9
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
10
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
11
+ require 'colorblind'
12
+ require 'rspec'
13
+ require 'active_support/buffered_logger'
14
+
15
+ # Requires supporting files with custom matchers and macros, etc,
16
+ # in ./support/ and its subdirectories.
17
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
18
+
19
+ RSpec.configure do |config|
20
+
21
+ end
metadata ADDED
@@ -0,0 +1,217 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: colorblind
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Oriol Gual
14
+ - Josep M. Bach
15
+ - Josep Jaume Rey
16
+ autorequire:
17
+ bindir: bin
18
+ cert_chain: []
19
+
20
+ date: 2010-09-15 00:00:00 +02:00
21
+ default_executable:
22
+ dependencies:
23
+ - !ruby/object:Gem::Dependency
24
+ type: :runtime
25
+ prerelease: false
26
+ name: activesupport
27
+ version_requirements: &id001 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - "="
31
+ - !ruby/object:Gem::Version
32
+ hash: 7
33
+ segments:
34
+ - 3
35
+ - 0
36
+ - 0
37
+ version: 3.0.0
38
+ requirement: *id001
39
+ - !ruby/object:Gem::Dependency
40
+ type: :development
41
+ prerelease: false
42
+ name: rspec
43
+ version_requirements: &id002 !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ hash: 62196431
49
+ segments:
50
+ - 2
51
+ - 0
52
+ - 0
53
+ - beta
54
+ - 22
55
+ version: 2.0.0.beta.22
56
+ requirement: *id002
57
+ - !ruby/object:Gem::Dependency
58
+ type: :development
59
+ prerelease: false
60
+ name: bundler
61
+ version_requirements: &id003 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ~>
65
+ - !ruby/object:Gem::Version
66
+ hash: 23
67
+ segments:
68
+ - 1
69
+ - 0
70
+ - 0
71
+ version: 1.0.0
72
+ requirement: *id003
73
+ - !ruby/object:Gem::Dependency
74
+ type: :development
75
+ prerelease: false
76
+ name: jeweler
77
+ version_requirements: &id004 !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ hash: -1876988218
83
+ segments:
84
+ - 1
85
+ - 5
86
+ - 0
87
+ - pre3
88
+ version: 1.5.0.pre3
89
+ requirement: *id004
90
+ - !ruby/object:Gem::Dependency
91
+ type: :runtime
92
+ prerelease: false
93
+ name: activesupport
94
+ version_requirements: &id005 !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - "="
98
+ - !ruby/object:Gem::Version
99
+ hash: 7
100
+ segments:
101
+ - 3
102
+ - 0
103
+ - 0
104
+ version: 3.0.0
105
+ requirement: *id005
106
+ - !ruby/object:Gem::Dependency
107
+ type: :development
108
+ prerelease: false
109
+ name: rspec
110
+ version_requirements: &id006 !ruby/object:Gem::Requirement
111
+ none: false
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ hash: 62196431
116
+ segments:
117
+ - 2
118
+ - 0
119
+ - 0
120
+ - beta
121
+ - 22
122
+ version: 2.0.0.beta.22
123
+ requirement: *id006
124
+ - !ruby/object:Gem::Dependency
125
+ type: :development
126
+ prerelease: false
127
+ name: bundler
128
+ version_requirements: &id007 !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ hash: 23
134
+ segments:
135
+ - 1
136
+ - 0
137
+ - 0
138
+ version: 1.0.0
139
+ requirement: *id007
140
+ - !ruby/object:Gem::Dependency
141
+ type: :development
142
+ prerelease: false
143
+ name: jeweler
144
+ version_requirements: &id008 !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ~>
148
+ - !ruby/object:Gem::Version
149
+ hash: -1876988218
150
+ segments:
151
+ - 1
152
+ - 5
153
+ - 0
154
+ - pre3
155
+ version: 1.5.0.pre3
156
+ requirement: *id008
157
+ description: Colorblind extends ActiveSupport logger with trendy colorschemes from the 90's!
158
+ email: info@codegram.com
159
+ executables: []
160
+
161
+ extensions: []
162
+
163
+ extra_rdoc_files:
164
+ - LICENSE
165
+ - README.rdoc
166
+ files:
167
+ - .document
168
+ - .gitignore
169
+ - .rspec
170
+ - .rvmrc
171
+ - Gemfile
172
+ - Gemfile.lock
173
+ - LICENSE
174
+ - README.rdoc
175
+ - Rakefile
176
+ - VERSION
177
+ - colorblind.gemspec
178
+ - lib/colorblind.rb
179
+ - spec/colorblind_spec.rb
180
+ - spec/spec_helper.rb
181
+ has_rdoc: true
182
+ homepage: http://github.com/codegram/colorblind
183
+ licenses: []
184
+
185
+ post_install_message:
186
+ rdoc_options: []
187
+
188
+ require_paths:
189
+ - lib
190
+ required_ruby_version: !ruby/object:Gem::Requirement
191
+ none: false
192
+ requirements:
193
+ - - ">="
194
+ - !ruby/object:Gem::Version
195
+ hash: 3
196
+ segments:
197
+ - 0
198
+ version: "0"
199
+ required_rubygems_version: !ruby/object:Gem::Requirement
200
+ none: false
201
+ requirements:
202
+ - - ">="
203
+ - !ruby/object:Gem::Version
204
+ hash: 3
205
+ segments:
206
+ - 0
207
+ version: "0"
208
+ requirements: []
209
+
210
+ rubyforge_project:
211
+ rubygems_version: 1.3.7
212
+ signing_key:
213
+ specification_version: 3
214
+ summary: Colorblind extends ActiveSupport logger with trendy colorschemes from the 90's!
215
+ test_files:
216
+ - spec/colorblind_spec.rb
217
+ - spec/spec_helper.rb