зеркало из https://github.com/github/ruby.git
Added force_require for binding.irb
When we make irb to bundled gems, binding.irb with bundle exec is not working without irb declaration of Gemfile. This force_require makes to load irb without Gemfile.
This commit is contained in:
Родитель
e43d701f09
Коммит
69d0e690bb
18
prelude.rb
18
prelude.rb
|
@ -1,12 +1,30 @@
|
|||
class Binding
|
||||
# :nodoc:
|
||||
def irb
|
||||
begin
|
||||
require 'irb'
|
||||
rescue LoadError
|
||||
force_require "irb" if defined?(Bundler)
|
||||
end
|
||||
irb
|
||||
end
|
||||
|
||||
# suppress redefinition warning
|
||||
alias irb irb # :nodoc:
|
||||
|
||||
private def force_require(gem)
|
||||
gemspecs = (Gem::Specification.dirs + [Gem.default_specifications_dir]).map{|d|
|
||||
Dir.glob("#{d}/#{gem}*.gemspec").reverse
|
||||
}.flatten
|
||||
if gemspecs.empty?
|
||||
false
|
||||
else
|
||||
gemspec = Gem::Specification.load(gemspecs[0])
|
||||
gemspec.dependencies.each{|dep| force_require dep.name }
|
||||
gemspec.activate
|
||||
require gem.gsub("-", "/")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module Kernel
|
||||
|
|
Загрузка…
Ссылка в новой задаче