mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Pry::Command::Edit: renamed some methods to improve grokkability
This commit is contained in:
parent
ba1f761557
commit
5302e3a154
1 changed files with 11 additions and 11 deletions
|
@ -47,22 +47,22 @@ class Pry
|
||||||
raise CommandError, "Only one of --ex, --temp, --in and FILE may be specified."
|
raise CommandError, "Only one of --ex, --temp, --in and FILE may be specified."
|
||||||
end
|
end
|
||||||
|
|
||||||
if local_edit?
|
if repl_edit?
|
||||||
# edit of local code, eval'd within pry.
|
# code defined in pry, eval'd within pry.
|
||||||
process_local_edit
|
repl_edit
|
||||||
elsif runtime_patch?
|
elsif runtime_patch?
|
||||||
# patch code without persisting changes
|
# patch code without persisting changes
|
||||||
apply_runtime_patch
|
apply_runtime_patch
|
||||||
else
|
else
|
||||||
# edit of remote code, eval'd at top-level
|
# code stored in actual files, eval'd at top-level
|
||||||
process_remote_edit
|
file_edit
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_local_edit
|
def repl_edit
|
||||||
content = Pry::Editor.edit_tempfile_with_content(initial_temp_file_content,
|
content = Pry::Editor.edit_tempfile_with_content(initial_temp_file_content,
|
||||||
initial_temp_file_content.lines.count)
|
initial_temp_file_content.lines.count)
|
||||||
if local_reload?
|
if repl_reload?
|
||||||
silence_warnings do
|
silence_warnings do
|
||||||
eval_string.replace content
|
eval_string.replace content
|
||||||
end
|
end
|
||||||
|
@ -81,7 +81,7 @@ class Pry
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_remote_edit
|
def file_edit
|
||||||
file_name, line = ContextLocator.new(self).file_and_line
|
file_name, line = ContextLocator.new(self).file_and_line
|
||||||
raise CommandError, "#{file_name} is not a valid file name, cannot edit!" if not_a_real_file?(file_name)
|
raise CommandError, "#{file_name} is not a valid file name, cannot edit!" if not_a_real_file?(file_name)
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ class Pry
|
||||||
Pry::CodeObject.lookup(args.first, target, _pry_)
|
Pry::CodeObject.lookup(args.first, target, _pry_)
|
||||||
end
|
end
|
||||||
|
|
||||||
def local_edit?
|
def repl_edit?
|
||||||
!opts.present?(:ex) && !opts.present?(:current) && args.empty?
|
!opts.present?(:ex) && !opts.present?(:current) && args.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -144,8 +144,8 @@ class Pry
|
||||||
opts.present?(:'no-reload') || Pry.config.disable_auto_reload
|
opts.present?(:'no-reload') || Pry.config.disable_auto_reload
|
||||||
end
|
end
|
||||||
|
|
||||||
# conditions much less strict than for reload? (which is for remote reloads)
|
# conditions much less strict than for reload? (which is for file-based reloads)
|
||||||
def local_reload?
|
def repl_reload?
|
||||||
!never_reload?
|
!never_reload?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue