term-colorizer 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +20 -0
- data/.rspec +2 -0
- data/.travis.yml +9 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +6 -0
- data/LICENSE.md +9 -0
- data/README.md +38 -0
- data/Rakefile +13 -0
- data/lib/term-colorizer/colorizer.rb +40 -0
- data/lib/term-colorizer/version.rb +5 -0
- data/lib/term-colorizer.rb +2 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/term-colorizer/colorizer_spec.rb +7 -0
- data/spec/term-colorizer/version_spec.rb +7 -0
- data/term-colorizer.gemspec +16 -0
- metadata +59 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MThmYTdhNTY2Y2NkZjI2ZDE0NWIzMjY5NGQ0M2Y0OTNkMzdmMjQyYg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YTUxOGUzMWNhNjViNWZjNzE0NmFkNDFmNDI5ZTQzMTA1NDgwOWNjYg==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
OWExNDMyZDQ5YmVmMDBjNGYzYjBlMWJlNzk0MDhlNDNmNzQ0MzExM2JjMTMx
|
10
|
+
NGFhZWFkZjBiMzk2ZmQwMmRlY2UyYzNlNDZhMzQ1NjhkZDQyNzRhNzg0ODFm
|
11
|
+
OGRjYjY1NzAxZDE4ODI3OTA5MDlhZTBjNzUxOWY2YWVkNzg0MTM=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZTY2NmU1MTgyMTU0M2E2OWJjZjk2NTUyZWM2MTU1ZGJiY2FkODQyYWU0OTVj
|
14
|
+
ZDZhYzQ0Y2FmMDYxYjFiZjYxOWMyZWMwYjUxYzU3OTUxYTZiNGIxMWRkZmQ1
|
15
|
+
M2ZiZjczMjMzZTkzZDlhY2QyMmJjODgzYzk4NjgzYmE3YjQ5ZGM=
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2013 Vishal Telangre.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
Term::Colorizer
|
2
|
+
===============
|
3
|
+
|
4
|
+
[![Build Status](https://travis-ci.org/vishaltelangre/term-colorizer.png?branch=master)](https://travis-ci.org/vishaltelangre/term-colorizer)
|
5
|
+
|
6
|
+
Print colorized strings on terminal (Useful for printing fancy logs)
|
7
|
+
|
8
|
+
## Usage
|
9
|
+
|
10
|
+
``` ruby
|
11
|
+
"Duck can quack".green
|
12
|
+
# => "\e[32mDuck can quack\e[0m"
|
13
|
+
|
14
|
+
puts "Wow, that's really " + "hot!".bright_red
|
15
|
+
# guess what it will do?
|
16
|
+
|
17
|
+
# Below are the bonus methods for your strings, which you can use as demonstrated above:
|
18
|
+
|
19
|
+
# black, red, green, yellow, blue, magenta, cyan, white, bright_black, bright_red,
|
20
|
+
# bright_green,bright_yellow, bright_blue, bright_magenta, bright_cyan, bright_white
|
21
|
+
```
|
22
|
+
|
23
|
+
:)
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
You're encouraged to contribute to this gem.
|
28
|
+
|
29
|
+
* Fork this project.
|
30
|
+
* Make changes, write tests.
|
31
|
+
* Updated [CHANGELOG](CHANGELOG.md).
|
32
|
+
* Make a pull request, bonus points for topic branches.
|
33
|
+
|
34
|
+
## Copyright and License
|
35
|
+
|
36
|
+
Copyright (c) 2013, Vishal Telangre and [Contributors](CHANGELOG.md). All Rights Reserved.
|
37
|
+
|
38
|
+
This project is licenced under the [MIT License](LICENSE.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
|
6
|
+
require 'rspec/core'
|
7
|
+
require 'rspec/core/rake_task'
|
8
|
+
|
9
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
10
|
+
spec.pattern = FileList["spec/**/*_spec.rb"]
|
11
|
+
end
|
12
|
+
|
13
|
+
task :default => :spec
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Term
|
2
|
+
module Colorizer
|
3
|
+
TERM_COLORS = %w{
|
4
|
+
black red green yellow blue magenta cyan white bright_black
|
5
|
+
bright_red bright_green bright_yellow bright_blue bright_magenta
|
6
|
+
bright_cyan bright_white
|
7
|
+
}
|
8
|
+
|
9
|
+
def method_missing(sym, *args, &block)
|
10
|
+
method = sym.to_s
|
11
|
+
super unless TERM_COLORS.include? method
|
12
|
+
self.send(method)
|
13
|
+
end
|
14
|
+
|
15
|
+
TERM_COLORS.each do |color|
|
16
|
+
case color
|
17
|
+
when "black" then define_method("black") { "\e[30m" + self.to_s + "\e[0m" }
|
18
|
+
when "red" then define_method("red") { "\e[31m" + self.to_s + "\e[0m" }
|
19
|
+
when "green" then define_method("green") { "\e[32m" + self.to_s + "\e[0m" }
|
20
|
+
when "yellow" then define_method("yellow") { "\e[33m" + self.to_s + "\e[0m" }
|
21
|
+
when "blue" then define_method("blue") { "\e[34m" + self.to_s + "\e[0m" }
|
22
|
+
when "magenta" then define_method("magenta") { "\e[35m" + self.to_s + "\e[0m" }
|
23
|
+
when "cyan" then define_method("cyan") { "\e[36m" + self.to_s + "\e[0m" }
|
24
|
+
when "white" then define_method("white") { "\e[37m" + self.to_s + "\e[0m" }
|
25
|
+
when "bright_black" then define_method("bright_black") { "\e[1m\e[30m" + self.to_s + "\e[0m" }
|
26
|
+
when "bright_red" then define_method("bright_red") { "\e[1m\e[31m" + self.to_s + "\e[0m" }
|
27
|
+
when "bright_green" then define_method("bright_green") { "\e[1m\e[32m" + self.to_s + "\e[0m" }
|
28
|
+
when "bright_yellow" then define_method("bright_yellow") { "\e[1m\e[33m" + self.to_s + "\e[0m" }
|
29
|
+
when "bright_blue" then define_method("bright_blue") { "\e[1m\e[34m" + self.to_s + "\e[0m" }
|
30
|
+
when "bright_magenta" then define_method("bright_magenta") { "\e[1m\e[35m" + self.to_s + "\e[0m" }
|
31
|
+
when "bright_cyan" then define_method("bright_cyan") { "\e[1m\e[36m" + self.to_s + "\e[0m" }
|
32
|
+
when "bright_white" then define_method("bright_white") { "\e[1m\e[37m" + self.to_s + "\e[0m" }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class String
|
39
|
+
include Term::Colorizer
|
40
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
require "term-colorizer/version"
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "term-colorizer"
|
6
|
+
s.version = Term::Colorizer::VERSION
|
7
|
+
s.authors = [ "Vishal Telangre" ]
|
8
|
+
s.email = "the@vishaltelangre.com"
|
9
|
+
s.platform = Gem::Platform::RUBY
|
10
|
+
s.required_rubygems_version = '>= 1.3.6'
|
11
|
+
s.files = `git ls-files`.split("\n")
|
12
|
+
s.require_paths = [ "lib" ]
|
13
|
+
s.homepage = "http://github.com/vishaltelangre/term-colorizer"
|
14
|
+
s.licenses = [ "MIT" ]
|
15
|
+
s.summary = "Print colorized strings on terminal (Useful for printing fancy logs)"
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: term-colorizer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Vishal Telangre
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-07-13 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email: the@vishaltelangre.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- .gitignore
|
20
|
+
- .rspec
|
21
|
+
- .travis.yml
|
22
|
+
- CHANGELOG.md
|
23
|
+
- Gemfile
|
24
|
+
- LICENSE.md
|
25
|
+
- README.md
|
26
|
+
- Rakefile
|
27
|
+
- lib/term-colorizer.rb
|
28
|
+
- lib/term-colorizer/colorizer.rb
|
29
|
+
- lib/term-colorizer/version.rb
|
30
|
+
- spec/spec_helper.rb
|
31
|
+
- spec/term-colorizer/colorizer_spec.rb
|
32
|
+
- spec/term-colorizer/version_spec.rb
|
33
|
+
- term-colorizer.gemspec
|
34
|
+
homepage: http://github.com/vishaltelangre/term-colorizer
|
35
|
+
licenses:
|
36
|
+
- MIT
|
37
|
+
metadata: {}
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ! '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: 1.3.6
|
52
|
+
requirements: []
|
53
|
+
rubyforge_project:
|
54
|
+
rubygems_version: 2.0.2
|
55
|
+
signing_key:
|
56
|
+
specification_version: 4
|
57
|
+
summary: Print colorized strings on terminal (Useful for printing fancy logs)
|
58
|
+
test_files: []
|
59
|
+
has_rdoc:
|