From 4fc757ece1dad0ccd4cbf70187a514495523b26d Mon Sep 17 00:00:00 2001 From: John Mair Date: Tue, 26 Apr 2011 03:19:55 +1200 Subject: [PATCH] extracted is_a_dynamically_defined_method? from check_for_dynamically_defined_method --- lib/pry/command_helpers.rb | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/pry/command_helpers.rb b/lib/pry/command_helpers.rb index fba0618f..c5d383db 100644 --- a/lib/pry/command_helpers.rb +++ b/lib/pry/command_helpers.rb @@ -56,9 +56,28 @@ class Pry end end - def check_for_dynamically_defined_method(meth) + def editor_with_start_line(line_number) + case Pry.editor + when /^[gm]?vi/, /^emacs/, /^nano/, /^pico/, /^gedit/, /^kate/ + "#{Pry.editor} +#{line_number}" + when /^mate/ + "#{Pry.editor} -l#{line_number}" + else + if RUBY_PLATFORM =~ /mswin|mingw/ + Pry.editor + else + "#{Pry.editor} +#{line_number}" + end + end + end + + def is_a_dynamically_defined_method?(meth) file, _ = meth.source_location - if file =~ /(\(.*\))|<.*>/ + !!(file =~ /(\(.*\))|<.*>/) + end + + def check_for_dynamically_defined_method(meth) + if is_a_dynamically_defined_method?(meth) raise "Cannot retrieve source for dynamically defined method." end end