Class: FacturaePrint::CLI
- Inherits:
-
Thor
- Object
- Thor
- FacturaePrint::CLI
- Defined in:
- lib/facturae_print/cli.rb
Instance Method Summary collapse
Instance Method Details
#html(facturae_xml, eruby_template) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/facturae_print/cli.rb', line 8 def html(facturae_xml, eruby_template) invoice = FacturaePrint::Invoice.new(File.read(facturae_xml)) template = File.read(eruby_template) html_renderer = FacturaePrint::Renderers::HTMLRenderer.new(template, invoice) rendered_html = html_renderer.render if [:output] File.open([:output], 'w') { |f| f.write(rendered_html) } else shell.say(rendered_html) end end |
#pdf(facturae_xml, eruby_template) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/facturae_print/cli.rb', line 25 def pdf(facturae_xml, eruby_template) invoice = FacturaePrint::Invoice.new(File.read(facturae_xml)) template = File.read(eruby_template) = {} [:stylesheet] = File.read([:stylesheet]) if [:stylesheet] pdf_renderer = FacturaePrint::Renderers::PDFRenderer.new(template, invoice, ) rendered_pdf = pdf_renderer.render if [:output] File.open([:output], 'w') { |f| f.write(rendered_pdf) } else shell.say(rendered_pdf) end end |