Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Reinstate the global "gem" function [Fixes #5]

  • Loading branch information...
commit 866637e2e2c8c5718d4905921b3ba32c318e8621 1 parent 3e6fa2e
@ConradIrwin authored
Showing with 34 additions and 5 deletions.
  1. +33 −4 lib/pry-debundle.rb
  2. +1 −1  pry-debundle.gemspec
View
37 lib/pry-debundle.rb
@@ -38,17 +38,16 @@ class << Pry
def debundle!
loaded = false
- # Rubygems 1.8
- if defined?(Gem.post_reset_hooks)
+ if rubygems_18?
Gem.post_reset_hooks.reject!{ |hook| hook.source_location.first =~ %r{/bundler/} }
Gem::Specification.reset
- load 'rubygems/custom_require.rb'
+ remove_bundler_mokeypatches
loaded = true
# Rubygems 1.6 — TODO might be quite slow.
elsif Gem.source_index && Gem.send(:class_variable_get, :@@source_index)
Gem.source_index.refresh!
- load 'rubygems/custom_require.rb'
+ remove_bundler_mokeypatches
loaded = true
else
@@ -76,6 +75,36 @@ def load_additional_plugins
new_plugins.each(&:activate!)
end
+
+ private
+
+ def rubygems_18?
+ defined?(Gem.post_reset_hooks)
+ end
+
+ # Ugh, this stuff is quite vile.
+ def remove_bundler_mokeypatches
+ load 'rubygems/custom_require.rb'
+
+ if rubygems_18?
+ Kernel.module_eval do
+ def gem(gem_name, *requirements) # :doc:
+ skip_list = (ENV['GEM_SKIP'] || "").split(/:/)
+ raise Gem::LoadError, "skipping #{gem_name}" if skip_list.include? gem_name
+ spec = Gem::Dependency.new(gem_name, *requirements).to_spec
+ spec.activate if spec
+ end
+ end
+ else
+ Kernel.module_eval do
+ def gem(gem_name, *requirements) # :doc:
+ skip_list = (ENV['GEM_SKIP'] || "").split(/:/)
+ raise Gem::LoadError, "skipping #{gem_name}" if skip_list.include? gem_name
+ Gem.activate(gem_name, *requirements)
+ end
+ end
+ end
+ end
end
# Run just after a binding.pry, before you get dumped in the REPL.
View
2  pry-debundle.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "pry-debundle"
- s.version = "0.3"
+ s.version = "0.4"
s.platform = Gem::Platform::RUBY
s.author = "Conrad Irwin"
s.email = "conrad.irwin@gmail.com"
Please sign in to comment.
Something went wrong with that request. Please try again.