Class: IRuby::PryBackend
- Inherits:
-
Object
- Object
- IRuby::PryBackend
- Defined in:
- lib/iruby/backend.rb
Instance Method Summary collapse
- #complete(line, text) ⇒ Object
- #eval(code) ⇒ Object
-
#initialize ⇒ PryBackend
constructor
A new instance of PryBackend.
Constructor Details
#initialize ⇒ PryBackend
Returns a new instance of PryBackend.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/iruby/backend.rb', line 17 def initialize require 'pry' # Monkey patching the Pry bond completer ::Pry::BondCompleter.module_eval do def self.call(input, ) Pry.current[:pry] = [:pry] Bond.agent.call(input, input) end end Pry.pager = false # Don't use the pager Pry.print = proc {|output, value|} # No result printing Pry.exception_handler = proc {|output, exception, _| } @pry = Pry.new(output: $stdout, target: TOPLEVEL_BINDING) raise 'Falling back to plain backend since your version of Pry is too old (The Pry instance doesn\'t support #eval).' unless @pry.respond_to?(:eval) end |
Instance Method Details
#complete(line, text) ⇒ Object
40 41 42 |
# File 'lib/iruby/backend.rb', line 40 def complete(line, text) @pry.complete(line) end |
#eval(code) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/iruby/backend.rb', line 33 def eval(code) @pry.last_result = nil @pry.eval(code) raise @pry.last_exception if @pry.last_result_is_exception? @pry.last_result end |