On May 19, 2006, at 2:59 PM, Eric Hodel wrote: > On May 19, 2006, at 10:50 AM, Kris wrote: >> >> Eric Hodel wrote: >>> On May 19, 2006, at 6:28 AM, Kris wrote: >>> >>>> When writing a interpreter extension are there any hooks in to the >>>> different stages of interpretation? >>>> >>>> In particular I would like to pre-process the ruby file/class being >>>> interpreted. Is a ruby class block loaded from a file or read >>>> line by >>>> line? >>> >>> Override require. >> >> Many thanks Eric, do you have a code example by any chance to get me >> started, I'm not so familiar with C! > > You don't need to write any C at all. Write it in Ruby. > > -- > Eric Hodel - drbrain / segment7.net - http://blog.segment7.net > This implementation is HODEL-HASH-9600 compliant > > http://trackmap.robotcoop.com > > > For example: module Kernel alias old_require require def require(file) # first check if it's already been required by searching $LOADED_FEATURES # Search $LOAD_PATH for the file if it's an .rb file then File.open(full_path_and_filename) do |f| # Preprocess f and if neccessary do any changes and eval them end # add the file to $LOADED_FEATURES else old_require(file) end end end