Class: BetterErrors::REPL::Pry
- Inherits:
-
Object
- Object
- BetterErrors::REPL::Pry
- Defined in:
- lib/better_errors/pry/repl/pry.rb
Defined Under Namespace
Instance Method Summary collapse
-
#initialize(binding, exception) ⇒ Pry
constructor
A new instance of Pry.
- #prompt ⇒ Object
- #send_input(str) ⇒ Object
- #store_last_exception(exception) ⇒ Object
Constructor Details
#initialize(binding, exception) ⇒ Pry
Returns a new instance of Pry.
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/better_errors/pry/repl/pry.rb', line 39 def initialize(binding, exception) @fiber = Fiber.new do @pry.repl binding end @input = BetterErrors::REPL::Pry::Input.new @output = BetterErrors::REPL::Pry::Output.new @pry = ::Pry.new input: @input, output: @output @pry.hooks.clear_all if defined?(@pry.hooks.clear_all) store_last_exception exception @fiber.resume end |
Instance Method Details
#prompt ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/better_errors/pry/repl/pry.rb', line 63 def prompt if indent = @pry.instance_variable_get(:@indent) and !indent.indent_level.empty? ["..", indent.indent_level] else [">>", ""] end rescue [">>", ""] end |
#send_input(str) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/better_errors/pry/repl/pry.rb', line 56 def send_input(str) local ::Pry.config, color: false, pager: false do @fiber.resume "#{str}\n" [@output.read_buffer, *prompt] end end |
#store_last_exception(exception) ⇒ Object
51 52 53 54 |
# File 'lib/better_errors/pry/repl/pry.rb', line 51 def store_last_exception(exception) return unless defined? ::Pry::LastException @pry.instance_variable_set(:@last_exception, ::Pry::LastException.new(exception.exception)) end |