terminal-display-colors 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ === 0.0.1 2010-05-25
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
@@ -0,0 +1,9 @@
1
+ demo.rb
2
+ History.txt
3
+ Manifest.txt
4
+ PostInstall.txt
5
+ README.rdoc
6
+ Rakefile
7
+ lib/terminal_display_colors.rb
8
+ test/test_helper.rb
9
+ test/test_terminal_display_colors.rb
@@ -0,0 +1,3 @@
1
+
2
+ For more information on terminal-display-colors, see http://github.com/davidcole/terminal-display-colors
3
+
@@ -0,0 +1,56 @@
1
+ = terminal-display-colors
2
+
3
+ http://github.com/davidcole/terminal-display-colors
4
+
5
+ == DESCRIPTION:
6
+
7
+ Adds color methods to String for easily adding color to terminal output.
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ * Displays strings as colored output.
12
+ * Displays strings as bold.
13
+
14
+ == SYNOPSIS:
15
+
16
+ require 'rubygems'
17
+ require 'terminal-display-colors'
18
+
19
+ puts 'red'.red
20
+ puts 'green'.green
21
+ puts 'blue'.blue
22
+
23
+ puts 'bold yellow'.yellow.bold
24
+
25
+ == REQUIREMENTS:
26
+
27
+ Ruby.
28
+
29
+ == INSTALL:
30
+
31
+ sudo gem install terminal-display-colors
32
+
33
+ == LICENSE:
34
+
35
+ (The MIT License)
36
+
37
+ Copyright (c) 2010 David Cole
38
+
39
+ Permission is hereby granted, free of charge, to any person obtaining
40
+ a copy of this software and associated documentation files (the
41
+ 'Software'), to deal in the Software without restriction, including
42
+ without limitation the rights to use, copy, modify, merge, publish,
43
+ distribute, sublicense, and/or sell copies of the Software, and to
44
+ permit persons to whom the Software is furnished to do so, subject to
45
+ the following conditions:
46
+
47
+ The above copyright notice and this permission notice shall be
48
+ included in all copies or substantial portions of the Software.
49
+
50
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
51
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
52
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
53
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
54
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
55
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
56
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ require 'rubygems'
2
+ gem 'hoe', '>= 2.1.0'
3
+ require 'hoe'
4
+ require 'fileutils'
5
+ require './lib/terminal_display_colors'
6
+
7
+ Hoe.plugin :newgem
8
+
9
+ # Generate the Rake tasks
10
+ $hoe = Hoe.spec 'terminal-display-colors' do
11
+ self.developer 'David Cole', 'davidcole@davidcole.net'
12
+ self.post_install_message = 'PostInstall.txt'
13
+ #self.rubyforge_name = 'display-colors'
14
+ self.readme_file = 'README.rdoc'
15
+
16
+ end
17
+
18
+ require 'newgem/tasks'
19
+ Dir['tasks/**/*.rake'].each { |t| load t }
data/demo.rb ADDED
@@ -0,0 +1,16 @@
1
+ require 'lib/terminal_display_colors'
2
+ include TerminalDispayColors
3
+
4
+ puts 'gray'.gray
5
+ puts 'red'.red
6
+ puts 'green'.green
7
+ puts 'yellow'.yellow
8
+ puts 'blue'.blue
9
+ puts 'purple'.purple
10
+ puts 'cyan'.cyan
11
+ puts 'white'.white
12
+
13
+
14
+ puts 'bold'.bold
15
+ puts 'bold red'.bold.red
16
+ puts 'red bold'.red.bold
@@ -0,0 +1,26 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ module TerminalDispayColors
5
+ VERSION = '0.0.1'
6
+
7
+ colors = {
8
+ 'gray' => "\033[30m",
9
+ 'red' => "\033[31m",
10
+ 'green' => "\033[32m",
11
+ 'yellow' => "\033[33m",
12
+ 'blue' => "\033[34m",
13
+ 'purple' => "\033[35m",
14
+ 'cyan' => "\033[36m",
15
+ 'white' => "\033[37m",
16
+ 'bold' => "\033[01m"
17
+ }
18
+ ending = "\033[00m"
19
+
20
+ colors.keys.each do | color |
21
+ color_block = lambda { | *args |
22
+ colors[ color ] + self + ending
23
+ }
24
+ String.send( :define_method, color.to_sym, color_block )
25
+ end
26
+ end
@@ -0,0 +1,2 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/../lib/terminal_display_colors'
@@ -0,0 +1,40 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestTerminalDispayColors < Test::Unit::TestCase
4
+
5
+ include TerminalDispayColors
6
+
7
+ def setup
8
+ end
9
+
10
+ def test_normal
11
+ assert_equal( "\e[30mtesting some gray text\e[00m", 'testing some gray text'.gray )
12
+ assert_equal( "\e[31mtesting some red text\e[00m", 'testing some red text'.red )
13
+ assert_equal( "\e[32mtesting some green text\e[00m", 'testing some green text'.green )
14
+ assert_equal( "\e[33mtesting some yellow text\e[00m", 'testing some yellow text'.yellow )
15
+ assert_equal( "\e[34mtesting some blue text\e[00m", 'testing some blue text'.blue )
16
+ assert_equal( "\e[35mtesting some purple text\e[00m", 'testing some purple text'.purple )
17
+ assert_equal( "\e[36mtesting some cyan text\e[00m", 'testing some cyan text'.cyan )
18
+ assert_equal( "\e[37mtesting some white text\e[00m", 'testing some white text'.white )
19
+ end
20
+
21
+ def test_bold
22
+ assert_equal( "\e[01m\e[30mtesting some gray text\e[00m\e[00m", 'testing some gray text'.gray.bold )
23
+ assert_equal( "\e[01m\e[31mtesting some red text\e[00m\e[00m", 'testing some red text'.red.bold )
24
+ assert_equal( "\e[01m\e[32mtesting some green text\e[00m\e[00m", 'testing some green text'.green.bold )
25
+ assert_equal( "\e[01m\e[33mtesting some yellow text\e[00m\e[00m", 'testing some yellow text'.yellow.bold )
26
+ assert_equal( "\e[01m\e[34mtesting some blue text\e[00m\e[00m", 'testing some blue text'.blue.bold )
27
+ assert_equal( "\e[01m\e[35mtesting some purple text\e[00m\e[00m", 'testing some purple text'.purple.bold )
28
+ assert_equal( "\e[01m\e[36mtesting some cyan text\e[00m\e[00m", 'testing some cyan text'.cyan.bold )
29
+ assert_equal( "\e[01m\e[37mtesting some white text\e[00m\e[00m", 'testing some white text'.white.bold )
30
+
31
+ assert_equal( "\e[30m\e[01mtesting some gray text\e[00m\e[00m", 'testing some gray text'.bold.gray )
32
+ assert_equal( "\e[31m\e[01mtesting some red text\e[00m\e[00m", 'testing some red text'.bold.red )
33
+ assert_equal( "\e[32m\e[01mtesting some green text\e[00m\e[00m", 'testing some green text'.bold.green )
34
+ assert_equal( "\e[33m\e[01mtesting some yellow text\e[00m\e[00m", 'testing some yellow text'.bold.yellow )
35
+ assert_equal( "\e[34m\e[01mtesting some blue text\e[00m\e[00m", 'testing some blue text'.bold.blue )
36
+ assert_equal( "\e[35m\e[01mtesting some purple text\e[00m\e[00m", 'testing some purple text'.bold.purple )
37
+ assert_equal( "\e[36m\e[01mtesting some cyan text\e[00m\e[00m", 'testing some cyan text'.bold.cyan )
38
+ assert_equal( "\e[37m\e[01mtesting some white text\e[00m\e[00m", 'testing some white text'.bold.white )
39
+ end
40
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: terminal-display-colors
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - David Cole
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-05-25 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rubyforge
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 7
30
+ segments:
31
+ - 2
32
+ - 0
33
+ - 4
34
+ version: 2.0.4
35
+ type: :development
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: hoe
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 23
46
+ segments:
47
+ - 2
48
+ - 6
49
+ - 0
50
+ version: 2.6.0
51
+ type: :development
52
+ version_requirements: *id002
53
+ description: Adds color methods to String for easily adding color to terminal output.
54
+ email:
55
+ - davidcole@davidcole.net
56
+ executables: []
57
+
58
+ extensions: []
59
+
60
+ extra_rdoc_files:
61
+ - History.txt
62
+ - Manifest.txt
63
+ - PostInstall.txt
64
+ files:
65
+ - demo.rb
66
+ - History.txt
67
+ - Manifest.txt
68
+ - PostInstall.txt
69
+ - README.rdoc
70
+ - Rakefile
71
+ - lib/terminal_display_colors.rb
72
+ - test/test_helper.rb
73
+ - test/test_terminal_display_colors.rb
74
+ has_rdoc: true
75
+ homepage: http://github.com/davidcole/terminal-display-colors
76
+ licenses: []
77
+
78
+ post_install_message: PostInstall.txt
79
+ rdoc_options:
80
+ - --main
81
+ - README.rdoc
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ hash: 3
90
+ segments:
91
+ - 0
92
+ version: "0"
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ hash: 3
99
+ segments:
100
+ - 0
101
+ version: "0"
102
+ requirements: []
103
+
104
+ rubyforge_project: terminal-display-colors
105
+ rubygems_version: 1.3.7
106
+ signing_key:
107
+ specification_version: 3
108
+ summary: Adds color methods to String for easily adding color to terminal output.
109
+ test_files:
110
+ - test/test_terminal_display_colors.rb
111
+ - test/test_helper.rb