Class: IRuby::PryBackend
- Inherits:
-
Object
- Object
- IRuby::PryBackend
- Includes:
- History
- Defined in:
- lib/iruby/backend.rb
Instance Attribute Summary collapse
-
#eval_path ⇒ Object
readonly
Returns the value of attribute eval_path.
Instance Method Summary collapse
- #complete(code) ⇒ Object
- #eval(code, store_history) ⇒ Object
- #eval_binding ⇒ Object
-
#initialize ⇒ PryBackend
constructor
A new instance of PryBackend.
- #reset ⇒ Object
Constructor Details
#initialize ⇒ PryBackend
Returns a new instance of PryBackend.
78 79 80 81 82 83 84 85 86 |
# File 'lib/iruby/backend.rb', line 78 def initialize require 'pry' Pry.memory_size = 3 Pry.pager = false # Don't use the pager Pry.print = proc {|output, value|} # No result printing Pry.exception_handler = proc {|output, exception, _| } @eval_path = Pry.eval_path reset end |
Instance Attribute Details
#eval_path ⇒ Object (readonly)
Returns the value of attribute eval_path.
75 76 77 |
# File 'lib/iruby/backend.rb', line 75 def eval_path @eval_path end |
Instance Method Details
#complete(code) ⇒ Object
119 120 121 |
# File 'lib/iruby/backend.rb', line 119 def complete(code) @pry.complete(code) end |
#eval(code, store_history) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/iruby/backend.rb', line 92 def eval(code, store_history) Pry.current_line = 1 @pry.last_result = nil unless @pry.eval(code) reset raise SystemExit end # Pry::Code.complete_expression? return false if !@pry.eval_string.empty? syntax_error = @pry.eval_string @pry.reset_eval_string @pry.evaluate_ruby(syntax_error) # Pry::Code.complete_expression? raise SyntaxError # evaluate again for current line number elsif @pry.last_result_is_exception? && @pry.last_exception.is_a?(SyntaxError) && @pry.last_exception.is_a?(Pry::UserError) @pry.evaluate_ruby(code) 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 |
#eval_binding ⇒ Object
88 89 90 |
# File 'lib/iruby/backend.rb', line 88 def eval_binding TOPLEVEL_BINDING end |
#reset ⇒ Object
123 124 125 |
# File 'lib/iruby/backend.rb', line 123 def reset @pry = Pry.new(output: $stdout, target: eval_binding) end |