Class: WebConsole::REPL::Pry

Inherits:
Object
  • Object
show all
Defined in:
lib/web_console/repl/pry.rb,
lib/web_console/repl/pry/version.rb

Defined Under Namespace

Classes: FiberInput

Constant Summary collapse

ENFORCED_UNSUPPORTED_OPTIONS =
{ color: false, pager: false }
VERSION =
"0.2.1"

Instance Method Summary collapse

Constructor Details

#initialize(binding = ::Pry.toplevel_binding) ⇒ Pry

Returns a new instance of Pry.



21
22
23
24
25
26
# File 'lib/web_console/repl/pry.rb', line 21

def initialize(binding = ::Pry.toplevel_binding)
  @binding = binding
  @input   = FiberInput.new
  @pry     = ::Pry.new(input: @input)
  @fiber   = Fiber.new { enforce_supported_options! { @pry.repl(binding) } }.tap(&:resume)
end

Instance Method Details

#promptObject



28
29
30
# File 'lib/web_console/repl/pry.rb', line 28

def prompt
  @pry.select_prompt(@input.previous, @binding)
end

#send_input(input) ⇒ Object



32
33
34
# File 'lib/web_console/repl/pry.rb', line 32

def send_input(input)
  Stream.threadsafe_capture! { @fiber.resume("#{input}\n") }
end