diff options
Diffstat (limited to 'prelude.rb')
| -rw-r--r-- | prelude.rb | 52 |
1 files changed, 39 insertions, 13 deletions
diff --git a/prelude.rb b/prelude.rb index 2b371e7134..b6c610dd58 100644 --- a/prelude.rb +++ b/prelude.rb @@ -1,15 +1,41 @@ -class Thread - MUTEX_FOR_THREAD_EXCLUSIVE = Mutex.new # :nodoc: - - # call-seq: - # Thread.exclusive { block } => obj - # - # Wraps a block in Thread.critical, restoring the original value - # upon exit from the critical section, and returns the value of the - # block. - def self.exclusive - MUTEX_FOR_THREAD_EXCLUSIVE.synchronize{ - yield - } +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. + def to_set(&block) + Set.new(self, &block) end end |
