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.
87 88 89 90 91 92 93 94 95 |
# File 'lib/iruby/backend.rb', line 87 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.
84 85 86 |
# File 'lib/iruby/backend.rb', line 84 def eval_path @eval_path end |
Instance Method Details
#complete(code) ⇒ Object
128 129 130 |
# File 'lib/iruby/backend.rb', line 128 def complete(code) @pry.complete(code) end |
#eval(code, store_history) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/iruby/backend.rb', line 101 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
97 98 99 |
# File 'lib/iruby/backend.rb', line 97 def eval_binding TOPLEVEL_BINDING end |
#reset ⇒ Object
132 133 134 |
# File 'lib/iruby/backend.rb', line 132 def reset @pry = Pry.new(output: $stdout, target: eval_binding) end |