Sha256: 64a0d9a71198dcba1144214c600a35cb24a01b6aeeee3e90c10e0ba4c99a2d0b

Contents?: true

Size: 1.41 KB

Versions: 6

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

require 'stringio'

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/util/xml_locate'
require 'br_invoices_pdf/util/nfce_check_urls'
require 'br_invoices_pdf/util/mount_params'
require 'br_invoices_pdf/util/enum'
require 'br_invoices_pdf/util/base_renderer'
require 'br_invoices_pdf/util/pdf_renderer'
require 'br_invoices_pdf/util/product_table'
require 'br_invoices_pdf/cfe'
require 'br_invoices_pdf/nfce'

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
br_invoices_pdf-0.2.24 lib/br_invoices_pdf.rb
br_invoices_pdf-0.2.23 lib/br_invoices_pdf.rb
br_invoices_pdf-0.2.22 lib/br_invoices_pdf.rb
br_invoices_pdf-0.2.21 lib/br_invoices_pdf.rb
br_invoices_pdf-0.2.20 lib/br_invoices_pdf.rb
br_invoices_pdf-0.2.19 lib/br_invoices_pdf.rb