class SiSU_Utils::CodeMarker
Public Class Methods
new(line,file,color=:red)
click to toggle source
# File lib/sisu/utils.rb, line 58 def initialize(line,file,color=:red) @line,@file,@color=line.to_s,file,color end
Public Instance Methods
ansi(color=nil)
click to toggle source
# File lib/sisu/utils.rb, line 61 def ansi(color=nil) @color=color ? color : @color c={} c[:on]=case @color when :red then ANSI_C[:red] when :green then ANSI_C[:green] when :yellow then ANSI_C[:yellow] when :blue then ANSI_C[:blue] when :fuchsia then ANSI_C[:fuchsia] when :cyan then ANSI_C[:cyan] when :inv_red then ANSI_C[:inv_red] when :inv_green then ANSI_C[:inv_green] when :inv_yellow then ANSI_C[:inv_yellow] when :inv_blue then ANSI_C[:inv_blue] when :inv_fuchsia then ANSI_C[:inv_fuchsia] when :inv_cyan then ANSI_C[:inv_cyan] when :b_red then ANSI_C[:b_red] when :b_green then ANSI_C[:b_green] when :b_yellow then ANSI_C[:b_yellow] when :b_blue then ANSI_C[:b_blue] when :b_fuchsia then ANSI_C[:b_fuchsia] when :b_cyan then ANSI_C[:b_cyan] else ANSI_C[:red] end c[:off]= ANSI_C[:off] #ansi_color + @line.to_s + ansi_color_off + ' ' + @file.gsub(/([^\/]+$)/,"#{ansi_color}\\1#{ansi_color_off}") c end
error(v=nil,x=nil)
click to toggle source
# File lib/sisu/utils.rb, line 164 def error(v=nil,x=nil) if (v.is_a?(Symbol) \ and x.is_a?(String)) x="\n " + '*ERROR* ' + x elsif v.is_a?(String) v="\n " + '*ERROR* ' + v x=nil else v,x='*ERROR*',nil end STDERR.puts set(v,x) end
mark(v=nil,x=nil)
click to toggle source
# File lib/sisu/utils.rb, line 131 def mark(v=nil,x=nil) puts set(v,x) end
message(msg='')
click to toggle source
# File lib/sisu/utils.rb, line 118 def message(msg='') @message=(msg.nil? || msg.empty?) \ ? '' : ' ' + msg end
ok(v=nil,x=nil)
click to toggle source
# File lib/sisu/utils.rb, line 140 def ok(v=nil,x=nil) if (v.is_a?(Symbol) \ and x.is_a?(String)) x= '*OK* ' + x elsif v.is_a?(String) v='*OK* ' + v x=nil else v,x='*OK*',nil end puts set(v,x) end
report(v=nil,x=nil)
click to toggle source
# File lib/sisu/utils.rb, line 137 def report(v=nil,x=nil) puts set(v,x) end
set(v=nil,x=nil)
click to toggle source
# File lib/sisu/utils.rb, line 123 def set(v=nil,x=nil) v=var(v,x) file,path=File.basename(@file),File.dirname(@file) v[:c][:on] + @line + v[:c][:off] + ' ' \ + path + '/' \ + "#{v[:c][:on]}#{file}#{v[:c][:off]}" \ + v[:m] end
tell(v=nil,x=nil)
click to toggle source
# File lib/sisu/utils.rb, line 134 def tell(v=nil,x=nil) puts set(v,x) end
var(v,x)
click to toggle source
# File lib/sisu/utils.rb, line 89 def var(v,x) h={ c: nil, m: '' } if v.is_a?(Hash) h[:c] = (defined? v[:c]) ? v[:c] : '' h[:m] = (defined? v[:m]) ? v[:m] : '' elsif (v.is_a?(Symbol) \ and x.is_a?(String)) if v.is_a?(Symbol) h[:c]=v elsif v.is_a?(String) h[:m]=v end if x.is_a?(String) h[:m]=x end elsif (v.is_a?(Symbol) \ or v.is_a?(String)) if v.is_a?(Symbol) h[:c]=v elsif v.is_a?(String) h[:m]=v end end h[:c] = (defined? h[:c]) ? h[:c] : '' h[:m] = (defined? h[:m]) ? h[:m] : '' h[:c]=ansi(h[:c]) h[:m]=message(h[:m]) h end
warn(v=nil,x=nil)
click to toggle source
# File lib/sisu/utils.rb, line 152 def warn(v=nil,x=nil) if (v.is_a?(Symbol) \ and x.is_a?(String)) x="\n " + '*WARN* ' + x elsif v.is_a?(String) v="\n " + '*WARN* ' + v x=nil else v,x='*WARN*',nil end puts set(v,x) end