Skip to content

Commit

Permalink
Rubocop fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kivanio committed Jan 12, 2024
1 parent e4e44e6 commit 5d90ed5
Show file tree
Hide file tree
Showing 57 changed files with 374 additions and 581 deletions.
2 changes: 1 addition & 1 deletion lib/brcobranca/boleto/ailos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Ailos < Base
validates_length_of :agencia, maximum: 4, message: 'deve ser menor ou igual a 4 dígitos.'
validates_length_of :conta_corrente,
maximum: 8,
message: "deve ser menor ou igual a 8 dígitos."
message: 'deve ser menor ou igual a 8 dígitos.'
validates_length_of :carteira, is: 2, message: 'deve ser menor ou igual a 2 dígitos.'
validates_length_of :convenio, is: 6, message: 'deve ser menor ou igual a 6 dígitos.'
validates_length_of :nosso_numero, maximum: 9, message: 'deve ser menor ou igual a 9 dígitos.'
Expand Down
8 changes: 4 additions & 4 deletions lib/brcobranca/boleto/banco_brasil.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ class BancoBrasil < Base
# Nova instancia do BancoBrasil
# @param (see Brcobranca::Boleto::Base#initialize)
def initialize(campos = {})
campos = {
carteira: '18',
codigo_servico: false,
campos = {
carteira: '18',
codigo_servico: false,
local_pagamento: 'PAGÁVEL EM QUALQUER BANCO.'
}.merge!(campos)
}.merge!(campos)
super(campos)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/brcobranca/boleto/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def initialize(campos = {})

campos = padrao.merge!(campos)
campos.each do |campo, valor|
send "#{campo}=", valor
send :"#{campo}=", valor
end

yield self if block_given?
Expand Down
2 changes: 1 addition & 1 deletion lib/brcobranca/boleto/citibank.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def agencia_conta_boleto
#
# @return [String]
def codigo_barras_segunda_parte
"#{carteira}#{portfolio}#{convenio[1..-1]}#{nosso_numero}#{nosso_numero_dv}"
"#{carteira}#{portfolio}#{convenio[1..]}#{nosso_numero}#{nosso_numero_dv}"
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/brcobranca/boleto/sicredi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def banco_dv
# @example
# boleto.nosso_numero_boleto #=> "14/200022-5"
def nosso_numero_boleto
"#{nosso_numero_with_byte_idt[0..1]}/#{nosso_numero_with_byte_idt[2..-1]}-#{nosso_numero_dv}"
"#{nosso_numero_with_byte_idt[0..1]}/#{nosso_numero_with_byte_idt[2..]}-#{nosso_numero_dv}"
end

def nosso_numero_codigo_barra
Expand Down
27 changes: 16 additions & 11 deletions lib/brcobranca/boleto/template/rghost.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def lote(boletos, options = {})
def method_missing(m, *args)
method = m.to_s
if method.start_with?('to_')
modelo_generico(self, (args.first || {}).merge!(formato: method[3..-1]))
modelo_generico(self, (args.first || {}).merge!(formato: method[3..]))
else
super
end
Expand Down Expand Up @@ -81,12 +81,13 @@ def modelo_generico(boleto, options = {})

# Gerando codigo de barra com rghost_barcode
if boleto.codigo_barras
doc.barcode_interleaved2of5(boleto.codigo_barras, width: '10.3 cm', height: '1.3 cm', x: "#{@x - 1.7} cm", y: "#{@y - 1.67} cm")
doc.barcode_interleaved2of5(boleto.codigo_barras, width: '10.3 cm', height: '1.3 cm', x: "#{@x - 1.7} cm",
y: "#{@y - 1.67} cm")
end

# Gerando stream
formato = (options.delete(:formato) || Brcobranca.configuration.formato)
resolucao = (options.delete(:resolucao) || Brcobranca.configuration.resolucao)
formato = options.delete(:formato) || Brcobranca.configuration.formato
resolucao = options.delete(:resolucao) || Brcobranca.configuration.resolucao
doc.render_stream(formato.to_sym, resolution: resolucao)
end

Expand All @@ -111,15 +112,16 @@ def modelo_generico_multipage(boletos, options = {})

# Gerando codigo de barra com rghost_barcode
if boleto.codigo_barras
doc.barcode_interleaved2of5(boleto.codigo_barras, width: '10.3 cm', height: '1.3 cm', x: "#{@x - 1.7} cm", y: "#{@y - 1.67} cm")
doc.barcode_interleaved2of5(boleto.codigo_barras, width: '10.3 cm', height: '1.3 cm', x: "#{@x - 1.7} cm",
y: "#{@y - 1.67} cm")
end

# Cria nova página se não for o último boleto
doc.next_page unless index == boletos.length - 1
end
# Gerando stream
formato = (options.delete(:formato) || Brcobranca.configuration.formato)
resolucao = (options.delete(:resolucao) || Brcobranca.configuration.resolucao)
formato = options.delete(:formato) || Brcobranca.configuration.formato
resolucao = options.delete(:resolucao) || Brcobranca.configuration.resolucao
doc.render_stream(formato.to_sym, resolution: resolucao)
end

Expand Down Expand Up @@ -190,9 +192,11 @@ def modelo_generico_cabecalho(doc, boleto)

move_more(doc, 0, -0.3)
doc.show boleto.sacado_endereco.to_s
if boleto.demonstrativo
doc.text_area boleto.demonstrativo, width: '18.5 cm', text_align: :left, x: "#{@x - 0.8} cm", y: "#{@y - 0.9} cm", row_height: '0.4 cm'
end
return unless boleto.demonstrativo

doc.text_area boleto.demonstrativo, width: '18.5 cm', text_align: :left, x: "#{@x - 0.8} cm",
y: "#{@y - 0.9} cm", row_height: '0.4 cm'

# FIM Primeira parte do BOLETO
end

Expand Down Expand Up @@ -263,7 +267,8 @@ def modelo_generico_rodape(doc, boleto)
doc.show boleto.valor_documento.to_currency

if boleto.instrucoes
doc.text_area boleto.instrucoes, width: '14 cm', text_align: :left, x: "#{@x -= 15.8} cm", y: "#{@y -= 0.9} cm", row_height: '0.4 cm'
doc.text_area boleto.instrucoes, width: '14 cm', text_align: :left, x: "#{@x -= 15.8} cm", y: "#{@y -= 0.9} cm",
row_height: '0.4 cm'
move_more(doc, 0, -2)
else
move_more(doc, -15.8, -0.9)
Expand Down
Loading

0 comments on commit 5d90ed5

Please sign in to comment.