removed Pry.active_instance from commands and replaced with _pry_ method

This commit is contained in:
John Mair 2011-08-16 13:02:32 +12:00
parent 3b5668f5fe
commit fb47d61215
7 changed files with 21 additions and 19 deletions

View File

@ -10,6 +10,7 @@ class Pry
attr_accessor :opts
attr_accessor :command_set
attr_accessor :command_processor
attr_accessor :_pry_
# Run a command from another command.
# @param [String] command_string The string that invokes the command

View File

@ -125,6 +125,7 @@ class Pry
context.eval_string = options[:eval_string]
context.arg_string = options[:arg_string]
context.command_set = commands
context._pry_ = @pry_instance
context.command_processor = self

View File

@ -8,11 +8,11 @@ class Pry
end
command "simple-prompt", "Toggle the simple prompt." do
case Pry.active_instance.prompt
case _pry_.prompt
when Pry::SIMPLE_PROMPT
Pry.active_instance.pop_prompt
_pry_.pop_prompt
else
Pry.active_instance.push_prompt Pry::SIMPLE_PROMPT
_pry_.push_prompt Pry::SIMPLE_PROMPT
end
end
@ -24,7 +24,7 @@ class Pry
next output.puts "Provide a command set name" if command_set.nil?
set = target.eval(arg_string)
Pry.active_instance.commands.import set
_pry_.commands.import set
end
command "reload-method", "Reload the source file that contains the specified method" do |meth_name|
@ -45,7 +45,7 @@ class Pry
end
command "req", "Require file(s) and expand their paths." do |*args|
args.each { |file_name| require File.expand_path(file_name) }
args.each { |file_name| load File.expand_path(file_name) }
end
command "reset", "Reset the REPL to a clean state." do

View File

@ -66,7 +66,7 @@ e.g amend-line puts 'hello again' # no line number modifies immediately preced
output.puts opt
end
opt.on_noopts { Pry.active_instance.input = StringIO.new(arg_string) }
opt.on_noopts { _pry_.input = StringIO.new(arg_string) }
end
if opts.m?
@ -81,7 +81,7 @@ e.g amend-line puts 'hello again' # no line number modifies immediately preced
range = opts.l? ? one_index_range_or_number(opts[:l]) : (0..-1)
range = (0..-2) if opts.o?
Pry.active_instance.input = StringIO.new(Array(code.each_line.to_a[range]).join)
_pry_.input = StringIO.new(Array(code.each_line.to_a[range]).join)
end
if opts.f?
@ -91,7 +91,7 @@ e.g amend-line puts 'hello again' # no line number modifies immediately preced
range = opts.l? ? one_index_range_or_number(opts[:l]) : (0..-1)
range = (0..-2) if opts.o?
Pry.active_instance.input = StringIO.new(Array(text_array[range]).join)
_pry_.input = StringIO.new(Array(text_array[range]).join)
end
end
@ -164,7 +164,7 @@ e.g amend-line puts 'hello again' # no line number modifies immediately preced
:as => Range,
:unless => :grep do |range|
actions = Array(history[range]).join("\n") + "\n"
Pry.active_instance.input = StringIO.new(actions)
_pry_.input = StringIO.new(actions)
end
opt.on "save", "Save history to a file. --save [start..end] output.txt. Pry commands are excluded from saved history.", true, :as => Range

View File

@ -150,7 +150,7 @@ class Pry
if opts[:p]
silence_warnings do
Pry.active_instance.input = StringIO.new(File.readlines(file_name).join)
_pry_.input = StringIO.new(File.readlines(file_name).join)
end
elsif should_reload
silence_warnings do

View File

@ -20,15 +20,15 @@ class Pry
end
command "shell-mode", "Toggle shell mode. Bring in pwd prompt and file completion." do
case Pry.active_instance.prompt
case _pry_.prompt
when Pry::SHELL_PROMPT
Pry.active_instance.pop_prompt
Pry.active_instance.custom_completions = Pry::DEFAULT_CUSTOM_COMPLETIONS
_pry_.pop_prompt
_pry_.custom_completions = Pry::DEFAULT_CUSTOM_COMPLETIONS
else
Pry.active_instance.push_prompt Pry::SHELL_PROMPT
Pry.active_instance.custom_completions = Pry::FILE_COMPLETIONS
_pry_.push_prompt Pry::SHELL_PROMPT
_pry_.custom_completions = Pry::FILE_COMPLETIONS
Readline.completion_proc = Pry::InputCompleter.build_completion_proc target,
Pry.active_instance.instance_eval(&Pry::FILE_COMPLETIONS)
_pry_.instance_eval(&Pry::FILE_COMPLETIONS)
end
end

View File

@ -7,7 +7,7 @@ class Pry
next output.puts("Provide an arg!") if arg.nil?
prime_string = "command #{arg_string}\n"
command_string = Pry.active_instance.r(target, prime_string)
command_string = _pry_.r(target, prime_string)
eval_string.replace <<-HERE
_pry_.commands.instance_eval do
@ -28,7 +28,7 @@ class Pry
load file_name
end
Pry.config.commands.import target.eval(set_name)
Pry.active_instance.commands.import target.eval(set_name)
_pry_.commands.import target.eval(set_name)
set_file_and_dir_locals(file_name)
end
@ -44,7 +44,7 @@ class Pry
load file_name
end
Pry.config.commands.import target.eval(set_name)
Pry.active_instance.commands.import target.eval(set_name)
_pry_.commands.import target.eval(set_name)
set_file_and_dir_locals(file_name)
end