FreedomCoder / colorize

Simple Colorize gem to display colors on the *nix console.

This URL has Read+Write access

colorize / README
56670859 » FreedomCoder 2008-08-27 This is the code 0.1 1 Something should go here , but well .. I have nothing more to say that it is a freebe
2 under GPL 3.0 licence :)
3
4 Cheers
5
6 FreedomCoder
8c5506d7 » FreedomCoder 2008-08-29 Introducing Module Colors f... 7
8
9 DOCS :
10
11 Colors:
12 :bold
13 :underline
14 :blink
15 :reverse
16 :concealed
17 :black
18 :red
19 :green
20 :yellow
21 :blue
22 :magenta
23 :cyan
24 :white
25 :on_black
26 :on_red
27 :on_green
28 :on_yellow
29 :on_blue
30 :on_magenta
31 :on_cyan
32 :on_white
33
a89ad017 » FreedomCoder 2008-09-25 New README file for github. 34 ===== test.rb ========
8c5506d7 » FreedomCoder 2008-08-29 Introducing Module Colors f... 35
a89ad017 » FreedomCoder 2008-09-25 New README file for github. 36 require "Colorize"
37
38 class Klass
39 include Colors
40 def initialize
41 system("echo #{red("hola")} This is a #{blue("test")}")
42 system("echo #{red on_white("Hola1")}")
43 puts "#{red on_blue("Hola2")}"
44 end
45 end
46
47 Klass.new
48
8c5506d7 » FreedomCoder 2008-08-29 Introducing Module Colors f... 49 html = "<html>
50 <body>
51 <dl>
a89ad017 » FreedomCoder 2008-09-25 New README file for github. 52 <dt>the first term</dt>
53 <dd>its definition</dd>
54
55 <dt>the second term</dt>
56 <dd>its definition</dd>
57
58 <dt>the third term</dt>
59 <dd>\"its definition\"</dd>
60 <img src=\"test.html\">
8c5506d7 » FreedomCoder 2008-08-29 Introducing Module Colors f... 61 </dl>
62 </body>
63 </html>"
64
a89ad017 » FreedomCoder 2008-09-25 New README file for github. 65 c = Colorize.new( :red => /<.*html>|<.*body>/,
8c5506d7 » FreedomCoder 2008-08-29 Introducing Module Colors f... 66 :blue => /".*"/,
67 :cyan => /src/)
68 puts c.paint(html)
a89ad017 » FreedomCoder 2008-09-25 New README file for github. 69
70 apachelog = "1.2.3.4 -- \"This is not\" - \"No way\".
71 4.3.2.1 -- \"This3 34 is not\" - \"No way 34343\".
72 4.3.2.1 -- \"This3 34 is not\" - \"No way 34343\"."
73 reg = /(.*) -- \"(.*)\" - \"(.*)\"\./
74
011df379 » FreedomCoder 2009-02-01 README changes to reflect code 75 apachelog = Colorize.block_paint apachelog, reg do |m|
a89ad017 » FreedomCoder 2008-09-25 New README file for github. 76 Colors.red(m[0]) + " -- \"" + Colors.blue(m[1]) + "\" - \"" + Colors.white(m[2]) + "\".\n"
77 end
78
011df379 » FreedomCoder 2009-02-01 README changes to reflect code 79 puts apachelog