s/Driver/REPL
This commit is contained in:
parent
46caa09077
commit
9d48aba5b8
|
@ -229,7 +229,7 @@ rescue LoadError
|
|||
end
|
||||
|
||||
require 'pry/version'
|
||||
require 'pry/driver'
|
||||
require 'pry/repl'
|
||||
require 'pry/rbx_method'
|
||||
require 'pry/rbx_path'
|
||||
require 'pry/code'
|
||||
|
|
|
@ -148,11 +148,10 @@ class Pry
|
|||
end
|
||||
end
|
||||
|
||||
driver = options[:driver] || Pry::Driver
|
||||
driver = options[:driver] || Pry::REPL
|
||||
|
||||
# Enter the matrix
|
||||
driver.new(options).repl
|
||||
|
||||
driver.start(options)
|
||||
rescue Pry::TooSafeException
|
||||
puts "ERROR: Pry cannot work with $SAFE > 0"
|
||||
raise
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
require 'forwardable'
|
||||
|
||||
class Pry
|
||||
class Driver
|
||||
class REPL
|
||||
extend Forwardable
|
||||
attr_accessor :pry
|
||||
|
||||
def_delegators :pry, :input, :output, :input_stack
|
||||
|
||||
def self.start(options)
|
||||
new(options).repl
|
||||
new(options).start
|
||||
end
|
||||
|
||||
def initialize(options)
|
||||
|
@ -15,14 +16,14 @@ class Pry
|
|||
@indent = Pry::Indent.new
|
||||
end
|
||||
|
||||
def repl
|
||||
def start
|
||||
repl_prologue
|
||||
|
||||
# FIXME: move these catchers back into Pry#accept_line
|
||||
break_data = nil
|
||||
exception = catch(:raise_up) do
|
||||
break_data = catch(:breakout) do
|
||||
repl_body
|
||||
repl
|
||||
end
|
||||
exception = false
|
||||
end
|
||||
|
@ -47,7 +48,7 @@ class Pry
|
|||
|
||||
end
|
||||
|
||||
def repl_body
|
||||
def repl
|
||||
loop do
|
||||
case val = retrieve_line
|
||||
when :control_c
|
|
@ -30,15 +30,15 @@ describe "Pry#input_stack" do
|
|||
|
||||
it 'input objects should be popped off stack as they are used up' do
|
||||
stack = [StringIO.new(":cloister\n"), StringIO.new(":baron\n")]
|
||||
driver = Pry::Driver.new :input => StringIO.new(":alex\n"),
|
||||
:output => @str_output,
|
||||
:input_stack => stack
|
||||
repl = Pry::REPL.new :input => StringIO.new(":alex\n"),
|
||||
:output => @str_output,
|
||||
:input_stack => stack
|
||||
stack.size.should == 2
|
||||
driver.send(:retrieve_line).should == ":alex\n"
|
||||
repl.send(:retrieve_line).should == ":alex\n"
|
||||
stack.size.should == 2
|
||||
driver.send(:retrieve_line).should == ":baron\n"
|
||||
repl.send(:retrieve_line).should == ":baron\n"
|
||||
stack.size.should == 1
|
||||
driver.send(:retrieve_line).should == ":cloister\n"
|
||||
repl.send(:retrieve_line).should == ":cloister\n"
|
||||
stack.size.should == 0
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue