-
Notifications
You must be signed in to change notification settings - Fork 0
/
.irbrc
95 lines (81 loc) · 2.69 KB
/
.irbrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
### START debundle.rb ###
# Copyright (c) Conrad Irwin <[email protected]> -- MIT License
# Source: https://github.com/ConradIrwin/pry-debundle
# Pry references removed by Jan Lelis <[email protected]>
module Debundle
VERSION = '0.7.d'
end
class << Debundle
# Break out of the Bundler jail.
#
# This can be used to load files in development that are not in your Gemfile (for
# example if you want to test something with a tool that you have locally).
#
# @example
# Debundle.debundle!
# require 'all_the_things'
#
# Normally you don't need to cal this directly though, as it is called for you when Pry
# starts.
#
# See https://github.com/carlhuda/bundler/issues/183 for some background.
#
def debundle!
return unless defined?(Bundler)
if rubygems_18_or_better?
if Gem.post_reset_hooks.reject!{ |hook| hook.source_location.first =~ %r{/bundler/} }
Gem::Specification.reset
remove_bundler_monkeypatches
end
# Rubygems 1.6 — TODO might be quite slow.
elsif Gem.source_index && Gem.send(:class_variable_get, :@@source_index)
Gem.source_index.refresh!
remove_bundler_monkeypatches
else
raise "No hacks found :("
end
rescue => e
puts "Debundling failed: #{e.message}"
puts "When reporting bugs to https://github.com/ConradIrwin/pry-debundle, please include:"
puts "* gem version: #{Gem::VERSION rescue 'undefined'}"
puts "* bundler version: #{Bundler::VERSION rescue 'undefined'}"
puts "* ruby version: #{RUBY_VERSION rescue 'undefined'}"
puts "* ruby engine: #{RUBY_ENGINE rescue 'undefined'}"
end
private
def rubygems_18_or_better?
defined?(Gem.post_reset_hooks)
end
def rubygems_20_or_better?
Gem::VERSION.to_i >= 2
end
# Ugh, this stuff is quite vile.
def remove_bundler_monkeypatches
if rubygems_20_or_better?
load 'rubygems/core_ext/kernel_require.rb'
else
load 'rubygems/custom_require.rb'
end
if rubygems_18_or_better?
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
Debundle.debundle!
### END debundle.rb ###
require 'irbtools'