2010-12-25 08:59:37 -05:00
|
|
|
class Pry
|
|
|
|
|
|
|
|
# class accessors
|
|
|
|
class << self
|
|
|
|
attr_reader :nesting
|
2010-12-27 05:56:55 -05:00
|
|
|
attr_accessor :last_result, :active_instance
|
2010-12-25 08:59:37 -05:00
|
|
|
attr_accessor :input, :output
|
2010-12-27 05:56:55 -05:00
|
|
|
attr_accessor :commands, :print, :hooks
|
2010-12-25 08:59:37 -05:00
|
|
|
attr_accessor :default_prompt, :wait_prompt
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.start(target=TOPLEVEL_BINDING, options={})
|
|
|
|
new(options).repl(target)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.view(obj)
|
|
|
|
case obj
|
|
|
|
when String, Array, Hash, Symbol, nil
|
|
|
|
obj.inspect
|
|
|
|
else
|
|
|
|
obj.to_s
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.reset_defaults
|
2010-12-25 09:18:30 -05:00
|
|
|
@input = Input.new
|
|
|
|
@output = Output.new
|
2010-12-26 08:39:46 -05:00
|
|
|
@commands = Commands.new(@output)
|
2010-12-25 09:18:30 -05:00
|
|
|
@default_prompt = DEFAULT_PROMPT
|
|
|
|
@wait_prompt = WAIT_PROMPT
|
2010-12-27 05:56:55 -05:00
|
|
|
@print = DEFAULT_PRINT
|
|
|
|
@hooks = DEFAULT_HOOKS
|
2010-12-25 08:59:37 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
self.reset_defaults
|
|
|
|
|
|
|
|
@nesting = []
|
|
|
|
def @nesting.level
|
|
|
|
last.is_a?(Array) ? last.first : nil
|
|
|
|
end
|
|
|
|
end
|