pry不会在断点处掉入REPL

时间:2017-11-25 03:05:01

标签: ruby pry

Pry不会在以下函数的断点处将我放入其REPL中。

def print_lines(data)
  puts "here's the input I got:"

  data.each_with_index do |line, index|
    url_regex = /(?:<a href=")(https?:\/{2}www.\w+[.](com|org|net)((\/\w+)*([.]\w+)?))(?:">)/

    binding.pry

    url = line.scan(url_regex)[0]

    puts "Line #{index}: #{url}"

  end

end

相反,它会产生以下输出:

From: /Users/hsb/work/hr-solutions/detect-html-links/lib/script.rb @ line 13 Object#print_lines:

4: def print_lines(data)
...
=> 13:     url = line.scan(url_regex)[0]
...
19: end
(END)

当我键入q时,pry会为循环的每个剩余迭代显示相同的输出。知道为什么我没有访问REPL来调查范围内的变量吗?

1 个答案:

答案 0 :(得分:0)

看起来STDIN的这个问题已经有了很好的记录!这个解决方案对我有用:http://rocket-science.ru/hacking/2015/09/02/pry-and-stdin

相关问题