Sha256: 13c942bbf7c539a083adacd6c9a3b588c3c7a73e905f89b0d1e41452c4b1408c

Contents?: true

Size: 1.03 KB

Versions: 9

Compression:

Stored size: 1.03 KB

Contents

require 'ox'
require 'prawn'
require 'prawn/table'
require 'chunky_png'
require 'rqrcode'
require 'barby'
require 'barby/barcode/code_128'
require 'barby/outputter/png_outputter'
require 'barby/outputter/prawn_outputter'

require 'br_invoices_pdf/version'
require 'br_invoices_pdf/generator'
require 'br_invoices_pdf/errors/invalid_document_type'

module BrInvoicesPdf
  @generators = {}

  module_function

  Ox.default_options = Ox.default_options.merge(encoding: 'windows-1252')

  def generate(type, xml, options = {})
    generator = @generators[type]
    raise(Errors::InvalidDocumentType, type) unless generator
    generator.generate(xml, options)
  end

  def register(type, renderer, parser)
    raise(ArgumentError, "Expected Symbol or String to type. Received #{type.class}") unless valid_type?(type)
    @generators[type.to_sym] = Generator.new(renderer, parser)
  end

  def supported_document_types
    @generators.keys
  end

  def valid_type?(type)
    type.is_a?(String) || type.is_a?(Symbol)
  end
end

require 'br_invoices_pdf/cfe'

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
br_invoices_pdf-0.2.6 lib/br_invoices_pdf.rb
br_invoices_pdf-0.2.6.alpha.18 lib/br_invoices_pdf.rb
br_invoices_pdf-0.2.5.alpha.17 lib/br_invoices_pdf.rb
br_invoices_pdf-0.2.5 lib/br_invoices_pdf.rb
br_invoices_pdf-0.2.5.alpha.16 lib/br_invoices_pdf.rb
br_invoices_pdf-0.2.4 lib/br_invoices_pdf.rb
br_invoices_pdf-0.2.4.alpha.15 lib/br_invoices_pdf.rb
br_invoices_pdf-0.2.4.alpha.14 lib/br_invoices_pdf.rb
br_invoices_pdf-0.2.3 lib/br_invoices_pdf.rb