Skip to content

Instantly share code, notes, and snippets.

@trans
Created July 13, 2010 11:22
Show Gist options
  • Save trans/473745 to your computer and use it in GitHub Desktop.
Save trans/473745 to your computer and use it in GitHub Desktop.
Where is date.rb coming from?
module Kernel
alias_method :old_require, :require
alias_method :old_load, :load
alias_method :old_autoload, :autoload
def require(path)
p "require: #{path}"
old_require(path)
end
module_function :require
def load(path, wrap=nil)
p "load: #{path}"
old_load(path, wrap)
end
module_function :load
def autoload(constant, path)
p "autoload: #{path}"
old_autoload(constant, path)
end
module_function :autoload
end
class Module
alias_method :old_autoload, :autoload
def autoload(constant, path)
p "autoload: #{path}"
old_autoload(constant, path)
end
def self.autoload(constant, path)
p "autoload: #{path}"
old_autoload(constant, path)
end
end
# now the test
l1 = $".dup
require 'yaml'
l2 = $".dup
puts "LOADING YAML DOCUMENT"
YAML.load <<-HERE
date: 2010-10-01
HERE
p $" - l2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment