Class: Pry::REPL

Inherits:
Object show all
Defined in:
lib/volt/cli/console.rb

Instance Method Summary collapse

Instance Method Details

#replObject

To make the console more useful, we make it so we flush the event registry after each line. This makes it so events are triggered after each line. To accomplish this we monkey-patch pry.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/volt/cli/console.rb', line 8

def repl
  loop do
    case val = read
    when :control_c
      output.puts ""
      pry.reset_eval_string
    when :no_more_input
      output.puts "" if output.tty?
      break
    else
      output.puts "" if val.nil? && output.tty?
      return pry.exit_value unless pry.eval(val)
    end

    # Flush after each line
    Volt::Computation.flush!
    Volt::Timers.flush_next_tick_timers!
  end
end