Created
August 24, 2009 13:36
-
-
Save koduki/173885 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
# intericense | |
require 'irb/completion' | |
# history | |
require 'irb/ext/save-history' | |
IRB.conf[:SAVE_HISTORY] = 1000 | |
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history" | |
# color | |
=begin | |
require 'wirble' | |
Wirble.init | |
Wirble.colorize | |
#conf.prompt_mode = :DEFAULT | |
=end | |
# command | |
def ls path = "" | |
print system('ls -CF ' + path ) | |
end | |
def cat filename | |
print open(filename).read | |
end | |
def cd(o) irb(o) end | |
# liblary | |
#require 'yaml' | |
#require 'rexml/document' | |
# tracer | |
def add_hook( klass, method, before, after ) | |
klass.instance_eval do | |
original = instance_method( method ) | |
define_method( method ) do | |
before.call( self) | |
begin | |
result = original.bind( self ).call | |
rescue Exception => e | |
after.call( self, nil, result, e ) | |
else | |
after.call( self, nil, result, nil ) | |
end | |
result | |
end | |
end | |
end | |
def trace(klass) | |
klass.instance_methods(false).each do |m| | |
add_hook(klass, m, lambda{puts "# start --- #{m}"}, lambda{puts "# end --- #{m}"}) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment