-
This file contains utility functions that are useful for the Runtime Library.
RubyBreaker is a dynamic instrumentation and monitoring tool that generates type documentation automatically for Ruby programs.
This constant contains the copyright information.
Extension used for files that contain type information in Ruby format
Options for RubyBreaker
This option parser may be used for the command-line mode or for the library mode when used with Rakefile. See rubybreaker/task.rb for how this can be used in the latter.
Extension used for files that contain RubyBreaker task information
Extension used for files that contain type information in YAML format
This method just redirects to Runtime’s method.
# File lib/rubybreaker/runtime.rb, line 93 def self.break(*mods) Runtime.break(*mods) end
This method just redirects to Runtime’s method. DEPRECATED: Use +::break+ to indicate the point of entry.
# File lib/rubybreaker/runtime.rb, line 88 def self.breakable(*mods) Runtime.breakable(*mods) end
# File lib/rubybreaker/runtime.rb, line 97 def self.check(*mods) Runtime.check(*mods) end
This method returns true if the logger is already created and false otherwise.
# File lib/rubybreaker/debug/debug.rb, line 13 def self.defined_logger?() return defined?(LOGGER) end
This method is for reporting an error to the user. It will immediately show the error message but also log it.
# File lib/rubybreaker/debug/debug.rb, line 44 def self.error(err, level=:error, &blk) msg = err.to_s msg = "#{msg} : #{yield}" if blk STDOUT.puts "[#{level.to_s.upcase}] #{msg}" LOGGER.send(level, msg) if defined?(OPTIONS) && OPTIONS[:debug] end
This method logs a non-error (or error) message but with the provided context.
# File lib/rubybreaker/debug/debug.rb, line 53 def self.log(str, level=:debug, context=nil, &blk) return unless defined?(OPTIONS) && OPTIONS[:debug] msg = str.to_s msg = "#{msg} : #{yield}" if blk if context output = "" pp = PrettyPrint.new(output) context.format_with_msg(pp,msg) pp.flush msg = output end LOGGER.send(level, msg) end
DEPRECATED: Use +::run+ to indicate the point of entry.
# File lib/rubybreaker/runtime.rb, line 83 def self.monitor() end
This method runs RubyBreaker for a particular test case (class). This is a bit different from running RubyBreaker as a shell program.
# File lib/rubybreaker.rb, line 175 def self.run(*mods) RubyBreaker.setup_logger() unless RubyBreaker.defined_logger?() # Task based run should use the rubybreaker options same as in shell # mode. So, parse the options first. if self.running_as_task?() # running in task mode RubyBreaker.verbose("Running RubyBreaker within a testcase") task = self.task OPTION_PARSER.parse(*task[:rubybreaker_opts]) Runtime.break(*task[:break]) Runtime.check(*task[:check]) task_name = task[:name] RubyBreaker.verbose("Done reading task information") io_file = self.io_file(task_name) elsif OPTIONS[:prog] # running in shell mode Runtime.break(*mods) # should not happen but for backward-compatibility Runtime.break(*OPTIONS[:break]) Runtime.check(*OPTIONS[:check]) io_file = self.io_file(OPTIONS[:prog_file]) else # Otherwise, assume there are no explicit IO files. end self.load_input(io_file) # The following is deprecated but doing this for backward compatibility Runtime.instrument() # At the end, we WILL generate an output of the type information. at_exit { self.output(io_file) } end
This method will display verbose message. It is not for debugging but to inform users of each stage in the analysis.
# File lib/rubybreaker/debug/debug.rb, line 30 def self.verbose(str, &blk) return unless defined?(OPTIONS) && (OPTIONS[:verbose] || OPTIONS[:debug]) if blk msg = yield msg = "#{str} : #{msg}" if str else msg = str end STDOUT.puts msg if OPTIONS[:verbose] LOGGER.info msg if OPTIONS[:debug] end