I created a Ruby script console that uses ARGF to load data from a file or stdin, which then calls Pry.
This works fine when I transfer the file to (Pry pauses), but it fails (Pry does not stop and just exits Ruby) when I transfer my data using stdin.
It's weird, does anyone know why? I would like to pass data through stdin and pause Pry.
Here is an example script:
require 'rubygems' require 'pry' def pry_it(str) binding.pry end pry_it(ARGF.read)
When I call this application with a file in ARGV, I get my correct answer - pry pauseing
% bundle exec ruby pry_test.rb file.txt From: /Users/wilcoxr/Development/json_pry/pry_test.rb @ line 8 Object
Fine! I can execute the Pry commands that I want
When I try to use STDIN to send data to my tool:
% cat file.txt | bundle exec ruby pry_test.rb From: /Users/wilcoxr/Development/json_pry/pry_test.rb @ line 8 Object
Look carefully: notice that I returned to the shell prompt, but it does not stop at IRB. Weird! I do not understand why I get this behavior ....
ruby pry
Ryanwilcox
source share