Sha256: 55a95c2a1471ee331c952508974077704f4de49094c9a16b77b3635bfb9defcf

Contents?: true

Size: 726 Bytes

Versions: 9

Compression:

Stored size: 726 Bytes

Contents

TOPLEVEL_BINDING = binding unless defined?(TOPLEVEL_BINDING)

def repl(scope = TOPLEVEL_BINDING)
  Repl.start(scope)
end

module Repl
  def self.start(scope = TOPLEVEL_BINDING)
    quitstr = ['quit', 'exit', '']
    while true
      stack = eval("caller[3..-1]", scope)
      print "\n#{stack.first}\n" if stack and not stack.empty?
      print 'rb> '
      input = gets.strip rescue 'quit'
      break if quitstr.include?(input)
      puts "=> #{
        begin
          eval(input, scope).inspect
        rescue LoadError => le
          puts le.inspect
        rescue SyntaxError => se
          puts se.inspect
        rescue => e
          puts e.inspect
        end
      }"
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
faster_rubygems-0.12.8 lib/faster_rubygems/ir_session.rb
faster_rubygems-0.12.7 lib/faster_rubygems/ir_session.rb
faster_rubygems-0.12.6 lib/faster_rubygems/ir_session.rb
faster_rubygems-0.12.5 lib/faster_rubygems/ir_session.rb
faster_rubygems-0.12.2 lib/faster_rubygems/ir_session.rb
faster_rubygems-0.12.1 lib/faster_rubygems/ir_session.rb
faster_rubygems-0.12.0 lib/faster_rubygems/ir_session.rb
faster_rubygems-0.11.1 lib/faster_rubygems/ir_session.rb
faster_rubygems-0.9.2 lib/faster_rubygems/ir_session.rb