From 49d2e2cbc275b201f24b15304b6a72a408df40ea Mon Sep 17 00:00:00 2001 From: Roque Pinel <1685896+repinel@users.noreply.github.com> Date: Thu, 21 Nov 2019 23:13:45 -0500 Subject: [PATCH] Silence Prince message `fin|success` Prince outputs `fin|success` to `err`. This change sends the `err` to the `log_file`. --- lib/princely/pdf.rb | 5 ++++- spec/princely/pdf_spec.rb | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/princely/pdf.rb b/lib/princely/pdf.rb index 76b7b2a..ac3fbe5 100644 --- a/lib/princely/pdf.rb +++ b/lib/princely/pdf.rb @@ -106,8 +106,11 @@ def initialize_pdf_from_string(string, output_file, options = {}) log_command path if options[:log_command] + # Make sure the log file exists before the pipe creation. + FileUtils.touch log_file + # Actually call the prince command, and pass the entire data stream back. - pdf = IO.popen(path, "w+") + pdf = IO.popen(path, "w+", err: log_file.to_s) pdf.puts string pdf end diff --git a/spec/princely/pdf_spec.rb b/spec/princely/pdf_spec.rb index ef761c8..74f517e 100644 --- a/spec/princely/pdf_spec.rb +++ b/spec/princely/pdf_spec.rb @@ -8,7 +8,7 @@ end it "generates a PDF from HTML" do - pdf = Princely::Pdf.new.pdf_from_string html_doc + pdf = Princely::Pdf.new(log_file: "/tmp/test_log").pdf_from_string html_doc expect(pdf).to start_with("%PDF-1.4") expect(pdf.rstrip).to end_with("%%EOF") pdf.length > 100