Module: BaseChip::Reporting::Methods

Defined in:
lib/reporting.rb

Instance Method Summary collapse

Instance Method Details

#class_stringObject



92
93
94
# File 'lib/reporting.rb', line 92

def class_string
  self.class.to_s.gsub(/BaseChip::/,'')
end

#debug(msg) ⇒ Object



68
69
70
# File 'lib/reporting.rb', line 68

def debug(msg)
  message "Debug", msg if $debug
end

#error(msg) ⇒ Object



51
52
53
54
55
# File 'lib/reporting.rb', line 51

def error(msg)
  re = ReportingError.new(msg)
  message "error", re.message, :red
  raise re
end

#fault(msg, exception_msg = nil) ⇒ Object



56
57
58
59
60
61
# File 'lib/reporting.rb', line 56

def fault(msg,exception_msg=nil)
  message "fault", msg, :red # = "#{Process.pid} #{$0} #{ARGV.join( ' ' )} #{msg}"
  DRb.stop_service
  # raise Fault, (exception_msg || msg) # FIXME -- when to raise?
  exit 0
end

#message(type, msg, color = nil) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/reporting.rb', line 71

def message(type,msg,color = nil)
  clear_line if self.respond_to? :clear_line
  ostring = case color
            when :red   ; ""
            when :green ; ""
            when nil    ; ''
            else raise
            end
  msg.chomp!
  if msg =~ /\n/
    ostring += "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
    ostring += "+++++ #{type}: (Multi-line) +++++++++++++++++++++++++++++++++++++++\n"
    ostring += "#{msg}\n"
    ostring += "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
  else
    ostring += "#{type}: #{msg}"
  end
  ostring += "" if color
  puts ostring
  ostring
end

#normal(msg) ⇒ Object



62
63
64
# File 'lib/reporting.rb', line 62

def normal(msg)
  puts msg unless $quiet
end

#verbose(msg) ⇒ Object



65
66
67
# File 'lib/reporting.rb', line 65

def verbose(msg)
  puts msg if $verbose
end