Skip to content

Instantly share code, notes, and snippets.

@koduki
Created August 24, 2009 13:36
Show Gist options
  • Save koduki/173885 to your computer and use it in GitHub Desktop.
Save koduki/173885 to your computer and use it in GitHub Desktop.
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