palett 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/CHANGELOG.md +5 -0
  2. data/LICENSE +20 -0
  3. data/README.md +27 -0
  4. data/lib/palett.rb +47 -0
  5. metadata +71 -0
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## 0.0.1 (June 16, 2011)
2
+
3
+ Features:
4
+
5
+ - initial import of this dummy gem
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Sergey Gerasimov (http://grsmv.com)
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.
data/README.md ADDED
@@ -0,0 +1,27 @@
1
+ Yet another one gem for terminal output coloring.
2
+
3
+ Usage:
4
+ ----
5
+
6
+ require 'palett'
7
+
8
+ # working with simple strings
9
+ puts 'Just red'.red
10
+ puts 'White on magenta '.white.magenta_background
11
+ puts 'Bold black on white'.black.white_background.bold
12
+
13
+ # working with blocks
14
+ white do
15
+ blue_background do
16
+ puts ( 'a'..'z' ).map { |l| l }.join(', ')
17
+ end
18
+ end
19
+
20
+ bold do
21
+ red do
22
+ white_background do
23
+ puts File.open('Agile_Manifesto').read
24
+ puts "-" * 50
25
+ end
26
+ end
27
+ nd
data/lib/palett.rb ADDED
@@ -0,0 +1,47 @@
1
+ require 'stringio'
2
+
3
+ module Kernel
4
+ def color text, code
5
+ "\e[#{code}m#{text}\e[0m"
6
+ end
7
+ end
8
+
9
+ module Palett
10
+
11
+ ANSI_PROPERTIES = {
12
+ 1 => 'bold', 4 => 'underline', 5 => 'blink',
13
+ 30 => 'black', 31 => 'red', 32 => 'green',
14
+ 33 => 'yellow', 34 => 'blue', 35 => 'magenta',
15
+ 36 => 'cyan', 37 => 'white', 40 => 'black_background',
16
+ 41 => 'red_background', 42 => 'green_background', 43 => 'yellow_background',
17
+ 44 => 'blue_background', 45 => 'magenta_background', 46 => 'cyan_background',
18
+ 47 => 'white_background'
19
+ }
20
+
21
+ ANSI_PROPERTIES.each do |code, name|
22
+ define_method name do
23
+ color self, code
24
+ end
25
+ end
26
+ end
27
+
28
+ class String
29
+ include Palett
30
+ end
31
+
32
+ class Object
33
+ include Palett
34
+
35
+ # TODO: READ STANDART OUTPUT TO STR AND COLORIZE IT
36
+ ANSI_PROPERTIES.each do |code, name|
37
+ eval <<-EOM
38
+ def #{name} &block
39
+ sio = StringIO.new
40
+ old_stdout, $stdout = $stdout, sio
41
+ yield
42
+ $stdout = old_stdout
43
+ puts sio.string.strip.#{name}
44
+ end
45
+ EOM
46
+ end
47
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: palett
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Sergey Gerasimov
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-07-14 00:00:00 +03:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Another one gem for terminal output coloring.
23
+ email:
24
+ - mail@grsmv.com
25
+ executables: []
26
+
27
+ extensions: []
28
+
29
+ extra_rdoc_files: []
30
+
31
+ files:
32
+ - README.md
33
+ - CHANGELOG.md
34
+ - LICENSE
35
+ - lib/palett.rb
36
+ has_rdoc: true
37
+ homepage: http://github.com/grsmv/day
38
+ licenses: []
39
+
40
+ post_install_message:
41
+ rdoc_options: []
42
+
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ hash: 3
51
+ segments:
52
+ - 0
53
+ version: "0"
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ requirements: []
64
+
65
+ rubyforge_project: palett
66
+ rubygems_version: 1.4.2
67
+ signing_key:
68
+ specification_version: 3
69
+ summary: Another one gem for terminal output coloring.
70
+ test_files: []
71
+