-
-
Save avdi/6131832 to your computer and use it in GitHub Desktop.
Open3.pipeline_r( | |
%W[xmllint --xinclude --xmlout #{spine_file}], | |
# In order to clean up extraneous namespace declarations we need a second | |
# xmllint process | |
%W[xmllint --format --nsclean --xmlout -]) do |output, wait_thr| | |
open(codex_file, 'w') do |f| | |
IO.copy_stream(output, f) | |
end | |
end |
That is awesome, see http://www.ruby-doc.org/stdlib-2.0/libdoc/open3/rdoc/Open3.html#method-c-pipeline_r for more details.
So it is basically piping the output from the first command into the input of the second command then passing the output of the last command to the block.
So command_one | command_two > OUTPUT
Right?
Yep. And then IO.copy_stream
pipes the output into a file. Yay!
The important thing is that these are real pipes - it's not collecting all the output from the first before it starts executing the second process.
I use your capture_stream block in metric_fu, but I still am in copypasta land with pipes. https://github.com/metricfu/metric_fu/pull/108/files#L2R37 https://github.com/metricfu/metric_fu/blob/297c64/lib/metric_fu/logging/mf_debugger.rb#L26
Wait, this does what?