How to require for the second time

listed in answer

How to require for the second time
0 votes, 0.00 avg. rating (0% score)

ANSWER:

You could write your own and put it in your .irbrc:

New Hotness

module Kernel
  # Untested
  def reload(lib)
    if found = $".find (.rb)?z/ }
      load found
    else
      require found
    end
  end
end

Minutes-Old and Therefore Busted

module Kernel
  # Untested
  def reload(lib)
    if File.exist?(lib)
      load lib
    else
      lib = "#lib.rb" unless File.extname(lib)=='.rb'
      $:.each do |dir|
        path = File.join(dir,lib)
        return load(path) if File.exist?(path)
      end
    end
  end
end

You’ll have to make it more robust if you want to support RubyGems.

by Phrogz from http://stackoverflow.com/questions/10306981