You can use the $LOADED_FEATURES
global to find the components of your gem and re-load them using the load
command (using require
won't work, as it skips items that Ruby has already processed):
task :console do
require 'irb'
require 'irb/completion'
require 'my_gem' # You know what to do.
def reload!
# Change 'my_gem' here too:
files = $LOADED_FEATURES.select { |feat| feat =~ /\/my_gem\// }
files.each { |file| load file }
end
ARGV.clear
IRB.start
end
Note this will fail if you are writing native extensions, you'll have to exclude them, and you'll want a compile step and to exit/re-start anyway if they change.