summaryrefslogtreecommitdiff
path: root/prelude.rb
blob: daeea5ed10124c7ade99c6a3ad5ee2b996825643 (plain)
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
class Binding
  # :nodoc:
  def irb(...)
    suppress = Thread.current[:__bundled_gems_warning_suppression]
    Thread.current[:__bundled_gems_warning_suppression] = ['reline', 'rdoc']

    begin
      require 'irb'
    rescue LoadError, Gem::LoadError
      Gem::BUNDLED_GEMS.force_activate 'irb'
      require 'irb'
    end
    irb(...)
  ensure
    Thread.current[:__bundled_gems_warning_suppression] = suppress
  end

  # suppress redefinition warning
  alias irb irb # :nodoc:
end

module Kernel
  # :stopdoc:
  def pp(*objs)
    require 'pp'
    pp(*objs)
  end

  # suppress redefinition warning
  alias pp pp

  private :pp
  # :startdoc:
end

module Enumerable
  # Makes a set from the enumerable object with given arguments.
  # Passing arguments to this method is deprecated.
  def to_set(*args, &block)
    klass = if args.empty?
      Set
    else
      warn "passing arguments to Enumerable#to_set is deprecated", uplevel: 1
      args.shift
    end
    klass.new(self, *args, &block)
  end
end