Pry.editor -> Pry.config.editor

This commit is contained in:
John Mair 2011-08-30 03:00:13 +12:00
parent 3e137e8b1b
commit 7509f6b6c1
3 changed files with 9 additions and 9 deletions

View File

@ -51,9 +51,9 @@ class Pry
# return value of that callable invocation is used as the exact
# shell command to invoke the editor.
# @example String
# Pry.editor = "emacsclient"
# Pry.config.editor = "emacsclient"
# @example Callable
# Pry.editor = proc { |file, line| "emacsclient #{file} +#{line}" }
# Pry.config.editor = proc { |file, line| "emacsclient #{file} +#{line}" }
# @return [String, #call]
attr_accessor :editor

View File

@ -112,7 +112,7 @@ class Pry
opts = Slop.parse!(args) do |opt|
opt.banner "Usage: edit [OPTIONS] [FILE]\n" \
"Edit the method FILE in an editor.\n" \
"Ensure #{text.bold("Pry.editor")} is set to your editor of choice.\n" \
"Ensure #{text.bold("Pry.config.editor")} is set to your editor of choice.\n" \
"e.g: edit sample.rb"
opt.on :r, "reload", "Eval file content after editing (evals at top level)"
@ -168,7 +168,7 @@ class Pry
opts = Slop.parse!(args) do |opt|
opt.banner "Usage: edit-method [OPTIONS] [METH]\n" \
"Edit the method METH in an editor.\n" \
"Ensure #{text.bold("Pry.editor")} is set to your editor of choice.\n" \
"Ensure #{text.bold("Pry.config.editor")} is set to your editor of choice.\n" \
"e.g: edit-method hello_method"
opt.on :M, "instance-methods", "Operate on instance methods."
@ -191,7 +191,7 @@ class Pry
next
end
next output.puts "Error: No editor set!\nEnsure that #{text.bold("Pry.editor")} is set to your editor of choice." if !Pry.editor
next output.puts "Error: No editor set!\nEnsure that #{text.bold("Pry.config.editor")} is set to your editor of choice." if !Pry.config.editor
if is_a_c_method?(meth)
output.puts "Error: Can't edit a C method."

View File

@ -333,10 +333,10 @@ class Pry
end
def invoke_editor(file, line)
if Pry.editor.respond_to?(:call)
editor_invocation = Pry.editor.call(file, line)
if Pry.config.editor.respond_to?(:call)
editor_invocation = Pry.config.editor.call(file, line)
else
editor_invocation = "#{Pry.editor} #{start_line_syntax_for_editor(file, line)}"
editor_invocation = "#{Pry.config.editor} #{start_line_syntax_for_editor(file, line)}"
end
run ".#{editor_invocation}"
@ -345,7 +345,7 @@ class Pry
def start_line_syntax_for_editor(file_name, line_number)
file_name = file_name.gsub(/\//, '\\') if RUBY_PLATFORM =~ /mswin|mingw/
case Pry.editor
case Pry.config.editor
when /^[gm]?vi/, /^emacs/, /^nano/, /^pico/, /^gedit/, /^kate/
"+#{line_number} #{file_name}"
when /^mate/, /^geany/