#My irbrc (Mathieu Martin => webmat on gmail)
#See http://programblings.com/2008/04/11/irbrc-for-the-runtime-tramp/
# for more information on tramp_require :-)

IRB_START_TIME = Time.now
puts IRB_START_TIME
IRB.conf[:AUTO_INDENT]=true

HASH = { :bob => 'Marley', :mom => 'Barley', :gods => 'Harley', :chris => 'Farley'}
ARRAY = HASH.keys

require 'rubygems'

$debug_irbrc=false

def tramp_require(what, &block)
loaded, require_result = false, nil

begin
puts('', "requiring #{what}") if $debug_irbrc
require_result = require what
loaded = true
puts "successfully required #{what}" if $debug_irbrc

rescue Exception => ex
puts "** Unable to require '#{what}'"
exception_details = "#{ex.class}: #{ex.message}"
if $debug_irbrc
ex.backtrace.reverse.each{|l| exception_details << "\n #{l}"}
else
exception_details.insert(0, "--> ")
end
puts exception_details
end

if loaded and block_given?
puts "executing block for #{what}" if $debug_irbrc
yield
end

require_result
end

=begin
#Equivalent implementation, without all the debugging noise :-)
def tramp_require(what, &block)
loaded, require_result = false, nil

begin
require_result = require what
loaded = true

rescue Exception => ex
puts "** Unable to require '#{what}'"
puts "--> #{ex.class}: #{ex.message}"
end

yield if loaded and block_given?

require_result
end
=end

tramp_require('duration') do
at_exit { puts Duration.new(Time.now - IRB_START_TIME) }
end

tramp_require 'what_methods'

tramp_require 'pp'

tramp_require('wirble') do
Wirble.init(:skip_prompt=>true)
Wirble.colorize
end