IMO the "proper" way to do this would be to use ruby_parser and ruby2ruby. (These are both gems, look them up.) You would first parse the Ruby code, then somehow split it into individual runnable chunks, convert each back into Ruby code with ruby2ruby and eval every single one. Of course, this will only work if at least the syntax of the file in question is correct. -- Matma Rex