Top Level Namespace
Defined Under Namespace
Modules: Clearbooks, Mixin Classes: Array, Hash, IO, String
Instance Method Summary collapse
- #clean(target) ⇒ Object
-
#colorize(color, message) ⇒ String
FIXME: Implement bold behavior FIXME: This method is currently b0rked.
- #egrep(pattern) ⇒ Object
-
#message(level, msg) ⇒ Object
Helpers: colorize.
Instance Method Details
#clean(target) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/clearbooks/interface/rake/library.rb', line 38 def clean target files = Dir.glob( File.join( target, "*" ) ) files.each do |file| print "(--) " sh "rm -vrf #{file.to_s}" if( File.exists?( "#{file.to_s}" ) ) end end |
#colorize(color, message) ⇒ String
FIXME: Implement bold behavior FIXME: This method is currently b0rked
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/clearbooks/interface/rake/library.rb', line 61 def colorize color, # Black 0;30 Dark Gray 1;30 # Blue 0;34 Light Blue 1;34 # Green 0;32 Light Green 1;32 # Cyan 0;36 Light Cyan 1;36 # Red 0;31 Light Red 1;31 # Purple 0;35 Light Purple 1;35 # Brown 0;33 Yellow 1;33 # Light Gray 0;37 White 1;37 colors = { "Gray" => "\e[1;30m", "LightGray" => "\e[0;37m", "Cyan" => "\e[0;36m", "LightCyan" => "\e[1;36m", "Blue" => "\e[0;34m", "LightBlue" => "\e[1;34m", "Green" => "\e[0;32m", "LightGreen" => "\e[1;32m", "Red" => "\e[0;31m", "LightRed" => "\e[1;31m", "LightRedBlink" => "\e[5;31m", "Purple" => "\e[0;35m", "LightPurple" => "\e[1;35m", "Brown" => "\e[0;33m", "Yellow" => "\e[1;33m", "White" => "\e[1;37m" } nocolor = "\e[0m" colors[ color ] + + nocolor end |
#egrep(pattern) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/clearbooks/interface/rake/library.rb', line 18 def egrep( pattern ) Dir[ "**/*.{rb,thor,rake}" ].each do |fn| count = 0 open(fn) do |f| while line = f.gets count += 1 STDOUT.puts "#{fn}:#{count}:#{line}" if line =~ pattern end end # end of open end # end of Dir.each end |
#message(level, msg) ⇒ Object
Helpers: colorize
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/clearbooks/interface/rake/library.rb', line 103 def level, msg symbols = { :info => [ "(--)", "Brown" ], :success => [ "(II)", "LightGreen" ], :error => [ "(EE)", "LightRed" ], :question => [ "(??)", "LightCyan" ], :debug => [ "(++)", "LightBlue" ], :warning => [ "(WW)", "Yellow" ] } raise ArugmentError, "Can't find the corresponding symbol for this message level (#{level.to_s}) - is the spelling wrong?" unless( symbols.key?( level ) ) if( level == :error ) STDERR.puts colorize( symbols[ level.to_sym ].last, "#{symbols[ level.to_sym ].first.to_s} #{msg.to_s}" ) else STDOUT.puts colorize( symbols[ level.to_sym ].last, "#{symbols[ level.to_sym ].first.to_s} #{msg.to_s}" ) end end |