2017-01-06 06:11:45 +03:00
|
|
|
class Binding
|
2018-10-26 20:08:30 +03:00
|
|
|
# :nodoc:
|
2017-01-06 06:11:45 +03:00
|
|
|
def irb
|
2024-09-17 06:36:19 +03:00
|
|
|
begin
|
|
|
|
require 'irb'
|
|
|
|
rescue LoadError, Gem::LoadError
|
|
|
|
force_activate 'irb'
|
|
|
|
retry
|
|
|
|
end
|
2017-01-06 06:11:45 +03:00
|
|
|
irb
|
|
|
|
end
|
2017-12-01 06:54:49 +03:00
|
|
|
|
|
|
|
# suppress redefinition warning
|
|
|
|
alias irb irb # :nodoc:
|
2024-09-06 07:06:56 +03:00
|
|
|
|
2024-09-06 07:24:04 +03:00
|
|
|
private def force_activate(gem)
|
2024-09-12 06:47:06 +03:00
|
|
|
Bundler.reset!
|
|
|
|
|
2024-09-12 08:14:37 +03:00
|
|
|
builder = Bundler::Dsl.new
|
2024-09-12 06:50:24 +03:00
|
|
|
if Bundler.definition.gemfiles.empty? # bundler/inline
|
2024-09-12 08:14:37 +03:00
|
|
|
Bundler.definition.locked_gems.specs.each{|spec| builder.gem spec.name, spec.version.to_s }
|
2024-09-12 06:50:24 +03:00
|
|
|
else
|
2024-09-12 08:14:37 +03:00
|
|
|
Bundler.definition.gemfiles.each{|gemfile| builder.eval_gemfile(gemfile) }
|
2024-09-12 06:50:24 +03:00
|
|
|
end
|
2024-09-12 08:14:37 +03:00
|
|
|
builder.gem gem
|
2024-09-12 06:47:06 +03:00
|
|
|
|
2024-09-12 08:14:37 +03:00
|
|
|
definition = builder.to_definition(nil, true)
|
2024-09-12 06:47:06 +03:00
|
|
|
definition.validate_runtime!
|
2024-09-12 08:30:22 +03:00
|
|
|
|
|
|
|
begin
|
|
|
|
orig_ui = Bundler.ui
|
|
|
|
orig_no_lock = Bundler::Definition.no_lock
|
|
|
|
|
|
|
|
ui = Bundler::UI::Shell.new
|
|
|
|
ui.level = "silent"
|
|
|
|
Bundler.ui = ui
|
|
|
|
Bundler::Definition.no_lock = true
|
|
|
|
|
|
|
|
Bundler::Runtime.new(nil, definition).setup
|
2024-09-12 09:46:57 +03:00
|
|
|
rescue Bundler::GemNotFound
|
|
|
|
warn "Failed to activate #{gem}, please install it with 'gem install #{gem}'"
|
2024-09-12 08:30:22 +03:00
|
|
|
ensure
|
|
|
|
Bundler.ui = orig_ui
|
|
|
|
Bundler::Definition.no_lock = orig_no_lock
|
|
|
|
end
|
2024-09-06 07:06:56 +03:00
|
|
|
end
|
2017-01-06 06:11:45 +03:00
|
|
|
end
|
2017-11-30 04:31:00 +03:00
|
|
|
|
|
|
|
module Kernel
|
|
|
|
def pp(*objs)
|
|
|
|
require 'pp'
|
2017-11-30 05:12:42 +03:00
|
|
|
pp(*objs)
|
2017-11-30 04:31:00 +03:00
|
|
|
end
|
2017-12-01 06:54:49 +03:00
|
|
|
|
|
|
|
# suppress redefinition warning
|
|
|
|
alias pp pp # :nodoc:
|
2018-10-11 04:03:05 +03:00
|
|
|
|
|
|
|
private :pp
|
2017-11-30 04:31:00 +03:00
|
|
|
end
|
2022-02-17 12:02:42 +03:00
|
|
|
|
|
|
|
autoload :Set, 'set'
|
|
|
|
|
|
|
|
module Enumerable
|
|
|
|
# Makes a set from the enumerable object with given arguments.
|
|
|
|
def to_set(klass = Set, *args, &block)
|
|
|
|
klass.new(self, *args, &block)
|
2023-03-08 23:00:13 +03:00
|
|
|
end unless instance_methods.include?(:to_set) # RJIT could already load this from builtin prelude
|
2022-02-17 12:02:42 +03:00
|
|
|
end
|