0

Pry does not drop me into its REPL at the breakpoint in the following function.

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

Instead, it produces the following output:

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)

When I type q, pry display the same output for each remaining iteration of the loop. Any idea why I'm not getting access to the REPL to investigate variables in the scope?

Hayden
  • 163
  • 1
  • 9
  • I was using STDIN to read in data. There seems to be some problem with pry and STDIN. Reading here https://stackoverflow.com/questions/32333962/pry-not-stopping-when-called-from-a-ruby-script-that-reads-from-stdin – Hayden Nov 25 '17 at 03:37

1 Answers1

0

It looks like this issue with STDIN are well documented! This solution worked for me: http://rocket-science.ru/hacking/2015/09/02/pry-and-stdin

Hayden
  • 163
  • 1
  • 9
  • 1
    This is not about “pry’s problems,” this is about pry’s smart enough to understand that standard input is now not something it can use for interactive operation. – Aleksei Matiushkin Nov 25 '17 at 04:45