Class: ReqresRspec::Formatters::Pdf
- Defined in:
- lib/reqres_rspec/formatters/pdf.rb
Instance Attribute Summary
Attributes inherited from Base
#logger, #output_path, #records
Instance Method Summary collapse
- #cleanup_pattern ⇒ Object
-
#write ⇒ Object
generates PDF file from existing HTML docs TODO: more info.
Methods inherited from Base
Constructor Details
This class inherits a constructor from ReqresRspec::Formatters::Base
Instance Method Details
#cleanup_pattern ⇒ Object
30 31 32 |
# File 'lib/reqres_rspec/formatters/pdf.rb', line 30 def cleanup_pattern 'reqres_rspec.pdf' end |
#write ⇒ Object
generates PDF file from existing HTML docs TODO: more info
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/reqres_rspec/formatters/pdf.rb', line 6 def write # http://www.princexml.com/download/ pdf_tool_path = 'prince' pdf_doc_path = File.join(output_path, 'reqres_rspec.pdf') if `which #{pdf_tool_path}`.size > 0 files = Dir["#{output_path}/*.html"] files.reject!{ |filename| filename.scan(/rspec_doc/).empty? } files.delete("#{output_path}/rspec_doc_table_of_content.html") files.unshift("#{output_path}/rspec_doc_table_of_content.html") if files.size > 0 files_arg = files.join('" "') `#{pdf_tool_path} "#{files_arg}" -o "#{pdf_doc_path}"` logger.info "ReqresRspec::Formatters::Pdf saved doc to #{pdf_doc_path}" if File.exists? pdf_doc_path else logger.error 'No HTML files found' end else logger.error "#{pdf_tool_path} is not installed! Check README.md for more info" end end |