class IRails::PryBackend

Public Class Methods

new() click to toggle source
# File lib/irails/backend.rb, line 55
def initialize
  require 'pry'
  Pry.pager = false # Don't use the pager
  Pry.print = proc {|output, value|} # No result printing
  Pry.exception_handler = proc {|output, exception, _| }
  reset
end

Public Instance Methods

complete(code) click to toggle source
# File lib/irails/backend.rb, line 74
def complete(code)
  @pry.complete(code)
end
eval(code, store_history) click to toggle source
# File lib/irails/backend.rb, line 63
def eval(code, store_history)
  @pry.last_result = nil
  unless @pry.eval(code)
    reset
    raise SystemExit
  end
  raise @pry.last_exception if @pry.last_result_is_exception?
  @pry.push_initial_binding unless @pry.current_binding # ensure that we have a binding
  @pry.last_result
end
reset() click to toggle source
# File lib/irails/backend.rb, line 78
def reset
  @pry = Pry.new(output: $stdout, target: TOPLEVEL_BINDING)
end