Skip to content

Instantly share code, notes, and snippets.

@arika
Created December 3, 2008 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arika/31537 to your computer and use it in GitHub Desktop.
Save arika/31537 to your computer and use it in GitHub Desktop.
# reload anoter version of RubyGems
lp0 = $:.dup
ENV["GEM_HOME"] = "/tmp/GEM"
$:.unshift "REL_1_1_1/lib"
p require "rubygems" #=> true
p Gem::RubyGemsVersion #=> "1.1.1"
gem "rails"
lp1 = $:.dup
Gem.loaded_specs.each do |name, spec|
spec.require_paths.each do |p|
$:.delete File.join(spec.full_gem_path, p)
end
end
class Object
remove_const(:Gem)
end
module Kernel
undef :gem
alias :require :gem_original_require
end
$".delete_if{|x| /^rubygems/=~x}
lp2 = $:.dup
ENV["GEM_HOME"] = "/tmp/GEM2"
$:.unshift "REL_1_3_1/lib"
p require "rubygems" #=> true
p Gem::RubyGemsVersion #=> "1.3.1"
lp3 = $:.dup
p [:lp0_lp1, lp1-lp0] #=> [:lp0_lp1, ["REL_1_1_1/lib", "/tmp/GEM/gems/rake-0.8.3/bin", "/tmp/GEM/gems/rake-0.8.3/lib", "/tmp/GEM/gems/activesupport-2.1.2/bin", "/tmp/GEM/gems/activesupport-2.1.2/lib", "/tmp/GEM/gems/activerecord-2.1.2/bin", "/tmp/GEM/gems/activerecord-2.1.2/lib", "/tmp/GEM/gems/actionpack-2.1.2/bin", "/tmp/GEM/gems/actionpack-2.1.2/lib", "/tmp/GEM/gems/actionmailer-2.1.2/bin", "/tmp/GEM/gems/actionmailer-2.1.2/lib", "/tmp/GEM/gems/activeresource-2.1.2/bin", "/tmp/GEM/gems/activeresource-2.1.2/lib", "/tmp/GEM/gems/rails-2.1.2/bin", "/tmp/GEM/gems/rails-2.1.2/lib"]]
p [:lp1_lp2, lp2-lp1] #=> [:lp1_lp2, []]
p [:lp0_lp2, lp2-lp0] #=> [:lp0_lp2, ["REL_1_1_1/lib"]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment