easy-color 0.1.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.
Files changed (2) hide show
  1. data/lib/easy-color.rb +67 -0
  2. metadata +47 -0
data/lib/easy-color.rb ADDED
@@ -0,0 +1,67 @@
1
+ ################################################################################
2
+ # Copyright (c) 2014, Mike 'Fuzzy' Partin <fuzzy@fu-manchu.org>
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are met:
7
+ #
8
+ # 1. Redistributions of source code must retain the above copyright notice, this
9
+ # list of conditions and the following disclaimer.
10
+ #
11
+ # 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ # this list of conditions and the following disclaimer in the documentation
13
+ # and/or other materials provided with the distribution.
14
+ #
15
+ # 3. Neither the name of the copyright holder nor the names of its contributors
16
+ # may be used to endorse or promote products derived from this software without
17
+ # specific prior written permission.
18
+ #
19
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
+ # POSSIBILITY OF SUCH DAMAGE.
30
+ ################################################################################
31
+
32
+ class String
33
+
34
+ # Normal colors
35
+ def black; colorize(self, "\e[0m\e[30"); end
36
+ def red; colorize(self, "\e[0m\e[31"); end
37
+ def green; colorize(self, "\e[0m\e[32"); end
38
+ def yellow; colorize(self, "\e[0m\e[33"); end
39
+ def blue; colorize(self, "\e[0m\e[34"); end
40
+ def purple; colorize(self, "\e[0m\e[35"); end
41
+ def cyan; colorize(self, "\e[0m\e[36"); end
42
+ def white; colorize(self, "\e[0m\e[37"); end
43
+
44
+ # Fun stuff
45
+ def clean; colorize(self, "\e[0"); end
46
+ def bold; colorize(self, "\e[1"); end
47
+ def underline; colorize(self, "\e[4"); end
48
+ def blink; colorize(self, "\e[5"); end
49
+ def reverse; colorize(self, "\e[7"); end
50
+ def conceal; colorize(self, "\e[8"); end
51
+
52
+ # Blanking
53
+ def clear_scr; colorize(self, "\e[2", mode="J"); end
54
+
55
+ # Placement
56
+ def place(line, column)
57
+ colorize(self, "\e[#{line};#{column}", mode='f')
58
+ end
59
+
60
+ def save_pos; colorize(self, "\e[", mode='s'); end
61
+ def return_pos; colorize(self, "\e[", mode='u'); end
62
+
63
+ def colorize(text, color_code, mode='m')
64
+ "#{color_code}#{mode}#{text}\e[0m"
65
+ end
66
+
67
+ end
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: easy-color
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Mike 'Fuzzy' Partin
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-04-16 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: A simple monkeypatch for String that adds support for standard ANSI escape
15
+ sequences, including color, video attributes, and cursor placement.
16
+ email: fuzzy@fu-manchu.org
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - lib/easy-color.rb
22
+ homepage: https://github.com/fuzzy/easy-color
23
+ licenses:
24
+ - BSD
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubyforge_project:
43
+ rubygems_version: 1.8.23
44
+ signing_key:
45
+ specification_version: 3
46
+ summary: Ansi color, attributes, and cursor placement methods for String.
47
+ test_files: []