Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

25 lines (16 sloc) 1.03 KB

Simulate Ruby 1.8, 1.9, JRuby’s set_trace_func and SCRIPT_LINES__ in Rubinius.

What is method Kernel#set_trace_func and constant SCRIPT_LINES___ ?

set_trace_func(proc) establishes proc as the handler for tracing or disables tracing if the parameter is nil.

if constaint __SCRIPT_LINES____ is defined and references a Hash, Ruby will store an entry containing the contents of each Ruby file it loads. The key for each hash entry is the file loaded as given by Ruby meta-constant “FILE” and the value is an Array of Strings with newlines containing the file contents.

Example of set_trace_func :

   require 'rubygems'; require 'set_trace'
   meth = lambda { |event, file, line, id, binding, classname|
     puts "tracer: #{event} #{file}:#{line}"
   set_trace_func meth

Example of SCRIPT_LINES__ :

   require 'rubygems'; require 'script_lines'
   SCRIPT_LINES__ = {}
   load 'foo.rb'
   # SCRIPT_LINES__ should have 'foo.rb' as a key and file contents as an Array
   # if it the 'foo.rb' loaded successfully.
Jump to Line
Something went wrong with that request. Please try again.