added whereami command based on ir_b

This commit is contained in:
John Mair 2011-03-05 17:29:25 +13:00
parent d299f3be30
commit 1b65cf19d5
2 changed files with 18 additions and 1 deletions

View File

@ -27,6 +27,23 @@ class Pry
remove_first_word = lambda do |text|
text.split.drop(1).join(' ')
end
command "whereami" do
file = target.eval '__FILE__'
ir_b_line = target.eval '__LINE__'
puts "#{file}:#{ir_b_line}"
File.open(file).each_with_index do |line, index|
line_n = index + 1
next unless line_n > (ir_b_line - 6)
break if line_n > (ir_b_line + 5)
if line_n == ir_b_line
puts " =>#{line_n.to_s.rjust(3)}: #{line.chomp}"
else
puts "#{line_n.to_s.rjust(6)}: #{line.chomp}"
end
end
end
command "!", "Clear the input buffer. Useful if the parsing process goes wrong and you get stuck in the read loop." do
output.puts "Input buffer cleared!"

View File

@ -1,3 +1,3 @@
class Pry
VERSION = "0.6.8pre4"
VERSION = "0.6.8pre6"
end