cnab 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/cnab.gemspec +1 -2
- data/lib/cnab.rb +12 -7
- data/lib/cnab/definition.rb +22 -0
- data/lib/cnab/definitions.rb +10 -0
- data/lib/cnab/definitions/header_arquivo.rb +14 -0
- data/lib/cnab/definitions/header_lote.rb +14 -0
- data/lib/cnab/definitions/segmento_t.rb +14 -0
- data/lib/cnab/definitions/segmento_u.rb +14 -0
- data/lib/cnab/definitions/trailer_arquivo.rb +14 -0
- data/lib/cnab/definitions/trailer_lote.rb +14 -0
- data/lib/cnab/detalhe.rb +5 -5
- data/lib/cnab/detalhe/segmento_t.rb +4 -31
- data/lib/cnab/detalhe/segmento_u.rb +4 -26
- data/lib/cnab/header_arquivo.rb +3 -25
- data/lib/cnab/header_lote/cobranca.rb +3 -24
- data/lib/cnab/helper.rb +3 -2
- data/lib/cnab/trailer_arquivo.rb +3 -9
- data/lib/cnab/trailer_lote/cobranca.rb +3 -16
- data/lib/cnab/version.rb +1 -1
- data/lib/cnab/versions/08.7/header_arquivo.yml +24 -0
- data/lib/cnab/versions/08.7/header_lote.yml +23 -0
- data/lib/cnab/versions/08.7/segmento_t.yml +29 -0
- data/lib/cnab/versions/08.7/segmento_u.yml +24 -0
- data/lib/cnab/versions/08.7/trailer_arquivo.yml +8 -0
- data/lib/cnab/versions/08.7/trailer_lote.yml +15 -0
- data/spec/cnab.txt +6 -0
- data/spec/cnab/definition_spec.rb +29 -0
- data/spec/cnab/definitions/header_arquivo_spec.rb +17 -0
- data/spec/cnab/definitions/header_lote_spec.rb +17 -0
- data/spec/cnab/definitions/segmento_t_spec.rb +17 -0
- data/spec/cnab/definitions/segmento_u_spec.rb +17 -0
- data/spec/cnab/definitions/trailer_arquivo_spec.rb +17 -0
- data/spec/cnab/definitions/trailer_lote_spec.rb +17 -0
- data/spec/cnab/detalhe/segmento_t_spec.rb +6 -2
- data/spec/cnab/detalhe/segmento_t_u_spec.rb +4 -2
- data/spec/cnab/detalhe/segmento_u_spec.rb +6 -2
- data/spec/cnab/detalhe_spec.rb +8 -6
- data/spec/cnab/header_arquivo_spec.rb +6 -2
- data/spec/cnab/header_lote/cobranca_spec.rb +6 -2
- data/spec/cnab/trailer_arquivo_spec.rb +6 -2
- data/spec/cnab_spec.rb +9 -40
- metadata +34 -20
data/cnab.gemspec
CHANGED
data/lib/cnab.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "cnab/version"
|
2
|
+
require "yaml"
|
2
3
|
|
3
4
|
module Cnab
|
4
5
|
autoload :HeaderArquivo, 'cnab/header_arquivo'
|
@@ -7,31 +8,35 @@ module Cnab
|
|
7
8
|
autoload :TrailerLote, 'cnab/trailer_lote'
|
8
9
|
autoload :Detalhe, 'cnab/detalhe'
|
9
10
|
autoload :Retorno, 'cnab/retorno'
|
11
|
+
autoload :Definition, 'cnab/definition'
|
12
|
+
autoload :Definitions, 'cnab/definitions'
|
10
13
|
|
11
14
|
autoload :Helper, 'cnab/helper'
|
12
15
|
autoload :Exceptions, 'cnab/exceptions'
|
13
16
|
|
14
|
-
def self.parse(file = nil, merge = false)
|
17
|
+
def self.parse(file = nil, merge = false, version = '08.7')
|
15
18
|
raise Exceptions::NoFileGiven if file.nil?
|
16
19
|
|
20
|
+
definition = Cnab::Definition.new(version)
|
21
|
+
|
17
22
|
File.open(file, 'rb') do |f|
|
18
|
-
header_arquivo = HeaderArquivo.new(f.gets)
|
19
|
-
header_lote = HeaderLote::Cobranca.new(f.gets)
|
23
|
+
header_arquivo = HeaderArquivo.new(f.gets, definition.header_arquivo)
|
24
|
+
header_lote = HeaderLote::Cobranca.new(f.gets, definition.header_lote)
|
20
25
|
|
21
26
|
detalhes = []
|
22
27
|
while(line = f.gets)
|
23
28
|
if line[7] == "5"
|
24
|
-
trailer_lote = TrailerLote::Cobranca.new(line)
|
29
|
+
trailer_lote = TrailerLote::Cobranca.new(line, definition.trailer_lote)
|
25
30
|
break
|
26
31
|
end
|
27
32
|
if merge
|
28
|
-
detalhes << Detalhe.merge(line, f.gets)
|
33
|
+
detalhes << Detalhe.merge(line, f.gets, definition)
|
29
34
|
else
|
30
|
-
detalhes << Detalhe.parse(line)
|
35
|
+
detalhes << Detalhe.parse(line, definition)
|
31
36
|
end
|
32
37
|
end
|
33
38
|
|
34
|
-
trailer_arquivo = TrailerArquivo.new(f.gets)
|
39
|
+
trailer_arquivo = TrailerArquivo.new(f.gets, definition.trailer_arquivo)
|
35
40
|
Retorno.new({ :header_arquivo => header_arquivo,
|
36
41
|
:header_lote => header_lote,
|
37
42
|
:detalhes => detalhes,
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Cnab
|
2
|
+
class Definition
|
3
|
+
def initialize(version)
|
4
|
+
@header_arquivo = Definitions::HeaderArquivo.new(version)
|
5
|
+
@header_lote = Definitions::HeaderLote.new(version)
|
6
|
+
@segmento_t = Definitions::SegmentoT.new(version)
|
7
|
+
@segmento_u = Definitions::SegmentoU.new(version)
|
8
|
+
@trailer_lote = Definitions::TrailerLote.new(version)
|
9
|
+
@trailer_arquivo = Definitions::TrailerArquivo.new(version)
|
10
|
+
end
|
11
|
+
|
12
|
+
def method_missing(method_name)
|
13
|
+
return instance_variable_get("@#{method_name}") if instance_variable_defined?("@#{method_name}")
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
def respond_to_missing?(method_name, include_private = false)
|
18
|
+
return true if instance_variable_defined?("@#{method_name}")
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Cnab
|
2
|
+
module Definitions
|
3
|
+
autoload :HeaderArquivo, 'cnab/definitions/header_arquivo'
|
4
|
+
autoload :HeaderLote, 'cnab/definitions/header_lote'
|
5
|
+
autoload :TrailerArquivo, 'cnab/definitions/trailer_arquivo'
|
6
|
+
autoload :TrailerLote, 'cnab/definitions/trailer_lote'
|
7
|
+
autoload :SegmentoT, 'cnab/definitions/segmento_t'
|
8
|
+
autoload :SegmentoU, 'cnab/definitions/segmento_u'
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Cnab
|
2
|
+
module Definitions
|
3
|
+
class HeaderArquivo
|
4
|
+
def initialize(version)
|
5
|
+
@definition = YAML.load_file("lib/cnab/versions/#{version}/header_arquivo.yml")
|
6
|
+
end
|
7
|
+
|
8
|
+
def method_missing(method)
|
9
|
+
range = @definition[method.to_s].split('..')
|
10
|
+
Range.new(range[0].to_i, range[1].to_i)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Cnab
|
2
|
+
module Definitions
|
3
|
+
class HeaderLote
|
4
|
+
def initialize(version)
|
5
|
+
@definition = YAML.load_file("lib/cnab/versions/#{version}/header_lote.yml")
|
6
|
+
end
|
7
|
+
|
8
|
+
def method_missing(method)
|
9
|
+
range = @definition[method.to_s].split('..')
|
10
|
+
Integer(range[0])..Integer(range[1])
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Cnab
|
2
|
+
module Definitions
|
3
|
+
class SegmentoT
|
4
|
+
def initialize(version)
|
5
|
+
@definition = YAML.load_file("lib/cnab/versions/#{version}/segmento_t.yml")
|
6
|
+
end
|
7
|
+
|
8
|
+
def method_missing(method)
|
9
|
+
range = @definition[method.to_s].split('..')
|
10
|
+
Integer(range[0])..Integer(range[1])
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Cnab
|
2
|
+
module Definitions
|
3
|
+
class SegmentoU
|
4
|
+
def initialize(version)
|
5
|
+
@definition = YAML.load_file("lib/cnab/versions/#{version}/segmento_u.yml")
|
6
|
+
end
|
7
|
+
|
8
|
+
def method_missing(method)
|
9
|
+
range = @definition[method.to_s].split('..')
|
10
|
+
Integer(range[0])..Integer(range[1])
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Cnab
|
2
|
+
module Definitions
|
3
|
+
class TrailerArquivo
|
4
|
+
def initialize(version)
|
5
|
+
@definition = YAML.load_file("lib/cnab/versions/#{version}/trailer_arquivo.yml")
|
6
|
+
end
|
7
|
+
|
8
|
+
def method_missing(method)
|
9
|
+
range = @definition[method.to_s].split('..')
|
10
|
+
Integer(range[0])..Integer(range[1])
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Cnab
|
2
|
+
module Definitions
|
3
|
+
class TrailerLote
|
4
|
+
def initialize(version)
|
5
|
+
@definition = YAML.load_file("lib/cnab/versions/#{version}/trailer_lote.yml")
|
6
|
+
end
|
7
|
+
|
8
|
+
def method_missing(method)
|
9
|
+
range = @definition[method.to_s].split('..')
|
10
|
+
Integer(range[0])..Integer(range[1])
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/cnab/detalhe.rb
CHANGED
@@ -4,19 +4,19 @@ module Cnab
|
|
4
4
|
autoload :SegmentoU, 'cnab/detalhe/segmento_u'
|
5
5
|
autoload :SegmentoTU, 'cnab/detalhe/segmento_t_u'
|
6
6
|
|
7
|
-
def self.parse(line)
|
7
|
+
def self.parse(line, definition)
|
8
8
|
case line[13]
|
9
9
|
when "T"
|
10
|
-
SegmentoT.new(line)
|
10
|
+
SegmentoT.new(line, definition.segmento_t)
|
11
11
|
when "U"
|
12
|
-
SegmentoU.new(line)
|
12
|
+
SegmentoU.new(line, definition.segmento_u)
|
13
13
|
else
|
14
14
|
raise Exceptions::SegmentNotImplemented
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
def self.merge(line1, line2)
|
19
|
-
SegmentoTU.new(parse(line1), parse(line2))
|
18
|
+
def self.merge(line1, line2, definition)
|
19
|
+
SegmentoTU.new(parse(line1, definition), parse(line2, definition))
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -3,39 +3,12 @@ module Cnab
|
|
3
3
|
class SegmentoT
|
4
4
|
include Helper
|
5
5
|
|
6
|
-
def initialize(line)
|
6
|
+
def initialize(line, definition)
|
7
7
|
raise Exceptions::LineNotParseable unless line.size == 242
|
8
8
|
|
9
|
-
@
|
10
|
-
@
|
11
|
-
@tipo_registro = line[7..7].strip
|
12
|
-
@num_registro = line[8..12].strip
|
13
|
-
@segmento = line[13..13].strip
|
14
|
-
@res_cnab1 = line[14..14].strip
|
15
|
-
@cod_movimentacao = line[15..16].strip
|
16
|
-
@agencia = line[17..21].strip
|
17
|
-
@dv_agencia = line[22..22].strip
|
18
|
-
@conta_corrente = line[23..34].strip
|
19
|
-
@dv_conta = line[35..35].strip
|
20
|
-
@dv_conta_agencia = line[36..36].strip
|
21
|
-
@id_titulo = line[37..56].strip
|
22
|
-
@carteira = line[57..57].strip
|
23
|
-
@doc_cobranca = line[58..72].strip
|
24
|
-
@vencimento = line[73..80].strip
|
25
|
-
@valor_titulo = line[81..95].strip
|
26
|
-
@banco_recebimento = line[96..98].strip
|
27
|
-
@ag_recebimento = line[99..103].strip
|
28
|
-
@dv_ag_recebimento = line[104..104].strip
|
29
|
-
@id_titulo_empresa = line[105..129].strip
|
30
|
-
@cod_moeda = line[130..131].strip
|
31
|
-
@tipo_inscricao = line[132..132].strip
|
32
|
-
@num_inscricao = line[133..147].strip
|
33
|
-
@nome = line[148..187].strip
|
34
|
-
@num_contrato = line[188..197].strip
|
35
|
-
@tarifa = line[198..212].strip
|
36
|
-
@motivo = line[213..222].strip
|
37
|
-
@res_cnab2 = line[223..239].strip
|
9
|
+
@line = line
|
10
|
+
@definition = definition
|
38
11
|
end
|
39
12
|
end
|
40
13
|
end
|
41
|
-
end
|
14
|
+
end
|
@@ -3,34 +3,12 @@ module Cnab
|
|
3
3
|
class SegmentoU
|
4
4
|
include Helper
|
5
5
|
|
6
|
-
def initialize(line)
|
6
|
+
def initialize(line, definition)
|
7
7
|
raise Exceptions::LineNotParseable unless line.size == 242
|
8
8
|
|
9
|
-
@
|
10
|
-
@
|
11
|
-
@tipo_registro = line[7..7].strip
|
12
|
-
@num_registro = line[8..12].strip
|
13
|
-
@segmento = line[13..13].strip
|
14
|
-
@res_cnab1 = line[14..14].strip
|
15
|
-
@cod_movimentacao = line[15..16].strip
|
16
|
-
@acrescimos = line[17..31].strip
|
17
|
-
@valor_desconto = line[32..46].strip
|
18
|
-
@valor_abatimento = line[47..61].strip
|
19
|
-
@valor_iof = line[62..76].strip
|
20
|
-
@valor_pago = line[77..91].strip
|
21
|
-
@valor_liquido = line[92..106].strip
|
22
|
-
@outras_despesas = line[107..122].strip
|
23
|
-
@outros_creditos = line[123..136].strip
|
24
|
-
@data_ocorrencia = line[137..144].strip
|
25
|
-
@data_credito = line[145..152].strip
|
26
|
-
@cod_ocorrencia_sacado = line[153..156].strip
|
27
|
-
@data_ocorrencia_sacado = line[157..164].strip
|
28
|
-
@valor_ocorrencia_sacado = line[165..179].strip
|
29
|
-
@compl_ocorrencia_sacado = line[180..209].strip
|
30
|
-
@banco_compensacao = line[210..212].strip
|
31
|
-
@banco_enviado = line[213..232].strip
|
32
|
-
@res_cnab2 = line[233..239].strip
|
9
|
+
@line = line
|
10
|
+
@definition = definition
|
33
11
|
end
|
34
12
|
end
|
35
13
|
end
|
36
|
-
end
|
14
|
+
end
|
data/lib/cnab/header_arquivo.rb
CHANGED
@@ -2,33 +2,11 @@ module Cnab
|
|
2
2
|
class HeaderArquivo
|
3
3
|
include Helper
|
4
4
|
|
5
|
-
def initialize(line)
|
5
|
+
def initialize(line, definition)
|
6
6
|
raise Exceptions::LineNotParseable unless line.size == 242
|
7
7
|
|
8
|
-
@
|
9
|
-
@
|
10
|
-
@registro = line[7..7].strip
|
11
|
-
@res_cnab1 = line[8..16].strip
|
12
|
-
@tipo_empresa = line[17..17].strip
|
13
|
-
@num_empresa = line[18..31].strip
|
14
|
-
@convenio = line[32..51].strip
|
15
|
-
@agencia = line[52..56].strip
|
16
|
-
@dv_agencia = line[57..57].strip
|
17
|
-
@conta_corrente = line[58..69].strip
|
18
|
-
@dv_conta = line[70..70].strip
|
19
|
-
@dv_conta_agencia = line[71..71].strip
|
20
|
-
@nome_empresa = line[72..101].strip
|
21
|
-
@nome_banco = line[102..131].strip
|
22
|
-
@res_cnab2 = line[132..141].strip
|
23
|
-
@cod_retorno = line[142..142].strip
|
24
|
-
@data_geracao_arq = line[143..150].strip
|
25
|
-
@hora_geracao_arq = line[151..156].strip
|
26
|
-
@sequencia = line[157..162].strip
|
27
|
-
@versao = line[163..165].strip
|
28
|
-
@densidade = line[166..170].strip
|
29
|
-
@res_banco = line[171..190].strip
|
30
|
-
@res_empresa = line[191..210].strip
|
31
|
-
@res_cnab3 = line[211..239].strip
|
8
|
+
@line = line
|
9
|
+
@definition = definition
|
32
10
|
end
|
33
11
|
end
|
34
12
|
end
|
@@ -3,32 +3,11 @@ module Cnab
|
|
3
3
|
class Cobranca
|
4
4
|
include Helper
|
5
5
|
|
6
|
-
def initialize(line)
|
6
|
+
def initialize(line, definition)
|
7
7
|
raise Exceptions::LineNotParseable unless line.size == 242
|
8
8
|
|
9
|
-
@
|
10
|
-
@
|
11
|
-
@registro = line[7..7].strip
|
12
|
-
@tipo_operacao = line[8..8].strip
|
13
|
-
@tipo_servico = line[9..10].strip
|
14
|
-
@res_cnab1 = line[11..12].strip
|
15
|
-
@layout_lote = line[13..15].strip
|
16
|
-
@res_cnab2 = line[16..16].strip
|
17
|
-
@tipo_empresa = line[17..17].strip
|
18
|
-
@num_empresa = line[18..32].strip
|
19
|
-
@convenio = line[33..52].strip
|
20
|
-
@agencia = line[53..57].strip
|
21
|
-
@dv_agencia = line[58..58].strip
|
22
|
-
@conta_corrente = line[59..70].strip
|
23
|
-
@dv_conta = line[71..71].strip
|
24
|
-
@dv_conta_agencia = line[72..72].strip
|
25
|
-
@nome_empresa = line[73..102].strip
|
26
|
-
@informacao1 = line[103..142].strip
|
27
|
-
@informacao2 = line[143..182].strip
|
28
|
-
@numero_remessa = line[183..190].strip
|
29
|
-
@data_gravacao = line[191..198].strip
|
30
|
-
@data_credito = line[199..206].strip
|
31
|
-
@res_cnab3 = line[207..239].strip
|
9
|
+
@line = line
|
10
|
+
@definition = definition
|
32
11
|
end
|
33
12
|
end
|
34
13
|
end
|
data/lib/cnab/helper.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
module Cnab
|
2
2
|
module Helper
|
3
3
|
def method_missing(method)
|
4
|
-
instance_variable_get("@#{method}")
|
4
|
+
return instance_variable_get("@#{method}") if instance_variable_defined?("@#{method}")
|
5
|
+
instance_variable_set("@#{method}", @line[@definition.send(method)].strip)
|
5
6
|
end
|
6
7
|
|
7
8
|
def respond_to_missing?(method_name, include_private = false)
|
8
|
-
return true unless
|
9
|
+
return true unless definition.respond_to?(method_name)
|
9
10
|
super
|
10
11
|
end
|
11
12
|
|
data/lib/cnab/trailer_arquivo.rb
CHANGED
@@ -2,17 +2,11 @@ module Cnab
|
|
2
2
|
class TrailerArquivo
|
3
3
|
include Helper
|
4
4
|
|
5
|
-
def initialize(line)
|
5
|
+
def initialize(line, definition)
|
6
6
|
raise Exceptions::LineNotParseable unless line.size == 242
|
7
7
|
|
8
|
-
@
|
9
|
-
@
|
10
|
-
@registro = line[7..7].strip
|
11
|
-
@res_cnab1 = line[8..16].strip
|
12
|
-
@qtd_lotes = line[17..22].strip
|
13
|
-
@qtd_registros = line[23..28].strip
|
14
|
-
@qtd_contas = line[29..34].strip
|
15
|
-
@res_cnab2 = line[35..239].strip
|
8
|
+
@line = line
|
9
|
+
@definition = definition
|
16
10
|
end
|
17
11
|
end
|
18
12
|
end
|
@@ -3,24 +3,11 @@ module Cnab
|
|
3
3
|
class Cobranca
|
4
4
|
include Helper
|
5
5
|
|
6
|
-
def initialize(line)
|
6
|
+
def initialize(line, definition)
|
7
7
|
raise Exceptions::LineNotParseable unless line.size == 242
|
8
8
|
|
9
|
-
@
|
10
|
-
@
|
11
|
-
@registro = line[7..7].strip
|
12
|
-
@res_cnab1 = line[8..16].strip
|
13
|
-
@qtd_registros = line[17..22].strip
|
14
|
-
@qtd_titulos_simples = line[23..28].strip
|
15
|
-
@valor_titulos_simples = line[29..45].strip
|
16
|
-
@qtd_titulos_vinculada = line[46..51].strip
|
17
|
-
@valor_titulos_simples = line[52..68].strip
|
18
|
-
@qtd_titulos_caucionada = line[69..74].strip
|
19
|
-
@valor_titulos_caucionada = line[75..91].strip
|
20
|
-
@qtd_titulos_descontada = line[92..97].strip
|
21
|
-
@valor_titulos_descontada = line[98..114].strip
|
22
|
-
@num_aviso = line[115..122].strip
|
23
|
-
@res_cnab3 = line[123..239].strip
|
9
|
+
@line = line
|
10
|
+
@definition = definition
|
24
11
|
end
|
25
12
|
end
|
26
13
|
end
|
data/lib/cnab/version.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
banco: 0..2
|
2
|
+
lote: 3..6
|
3
|
+
registro: 7..7
|
4
|
+
res_cnab1: 8..16
|
5
|
+
tipo_empresa: 17..17
|
6
|
+
num_empresa: 18..31
|
7
|
+
convenio: 32..51
|
8
|
+
agencia: 52..56
|
9
|
+
dv_agencia: 57..57
|
10
|
+
conta_corrente: 58..69
|
11
|
+
dv_conta: 70..70
|
12
|
+
dv_conta_agencia: 71..71
|
13
|
+
nome_empresa: 72..101
|
14
|
+
nome_banco: 102..131
|
15
|
+
res_cnab2: 132..141
|
16
|
+
cod_retorno: 142..142
|
17
|
+
data_geracao_arq: 143..150
|
18
|
+
hora_geracao_arq: 151..156
|
19
|
+
sequencia: 157..162
|
20
|
+
versao: 163..165
|
21
|
+
densidade: 166..170
|
22
|
+
res_banco: 171..190
|
23
|
+
res_empresa: 191..210
|
24
|
+
res_cnab3: 211..239
|
@@ -0,0 +1,23 @@
|
|
1
|
+
banco: 0..2
|
2
|
+
lote: 3..6
|
3
|
+
registro: 7..7
|
4
|
+
tipo_operacao: 8..8
|
5
|
+
tipo_servico: 9..10
|
6
|
+
res_cnab1: 11..12
|
7
|
+
layout_lote: 13..15
|
8
|
+
res_cnab2: 16..16
|
9
|
+
tipo_empresa: 17..17
|
10
|
+
num_empresa: 18..32
|
11
|
+
convenio: 33..52
|
12
|
+
agencia: 53..57
|
13
|
+
dv_agencia: 58..58
|
14
|
+
conta_corrente: 59..70
|
15
|
+
dv_conta: 71..71
|
16
|
+
dv_conta_agencia: 72..72
|
17
|
+
nome_empresa: 73..102
|
18
|
+
informacao1: 103..142
|
19
|
+
informacao2: 143..182
|
20
|
+
numero_remessa: 183..190
|
21
|
+
data_gravacao: 191..198
|
22
|
+
data_credito: 199..206
|
23
|
+
res_cnab3: 207..239
|
@@ -0,0 +1,29 @@
|
|
1
|
+
banco: 0..2
|
2
|
+
lote: 3..6
|
3
|
+
tipo_registro: 7..7
|
4
|
+
num_registro: 8..12
|
5
|
+
segmento: 13..13
|
6
|
+
res_cnab1: 14..14
|
7
|
+
cod_movimentacao: 15..16
|
8
|
+
agencia: 17..21
|
9
|
+
dv_agencia: 22..22
|
10
|
+
conta_corrente: 23..34
|
11
|
+
dv_conta: 35..35
|
12
|
+
dv_conta_agencia: 36..36
|
13
|
+
id_titulo: 37..56
|
14
|
+
carteira: 57..57
|
15
|
+
doc_cobranca: 58..72
|
16
|
+
vencimento: 73..80
|
17
|
+
valor_titulo: 81..95
|
18
|
+
banco_recebimento: 96..98
|
19
|
+
ag_recebimento: 99..103
|
20
|
+
dv_ag_recebimento: 104..104
|
21
|
+
id_titulo_empresa: 105..129
|
22
|
+
cod_moeda: 130..131
|
23
|
+
tipo_inscricao: 132..132
|
24
|
+
num_inscricao: 133..147
|
25
|
+
nome: 148..187
|
26
|
+
num_contrato: 188..197
|
27
|
+
tarifa: 198..212
|
28
|
+
motivo: 213..222
|
29
|
+
res_cnab2: 223..239
|
@@ -0,0 +1,24 @@
|
|
1
|
+
banco: 0..2
|
2
|
+
lote: 3..6
|
3
|
+
tipo_registro: 7..7
|
4
|
+
num_registro: 8..12
|
5
|
+
segmento: 13..13
|
6
|
+
res_cnab1: 14..14
|
7
|
+
cod_movimentacao: 15..16
|
8
|
+
acrescimos: 17..31
|
9
|
+
valor_desconto: 32..46
|
10
|
+
valor_abatimento: 47..61
|
11
|
+
valor_iof: 62..76
|
12
|
+
valor_pago: 77..91
|
13
|
+
valor_liquido: 92..106
|
14
|
+
outras_despesas: 107..122
|
15
|
+
outros_creditos: 123..136
|
16
|
+
data_ocorrencia: 137..144
|
17
|
+
data_credito: 145..152
|
18
|
+
cod_ocorrencia_sacado: 153..156
|
19
|
+
data_ocorrencia_sacado: 157..164
|
20
|
+
valor_ocorrencia_sacado: 165..179
|
21
|
+
compl_ocorrencia_sacado: 180..209
|
22
|
+
banco_compensacao: 210..212
|
23
|
+
banco_enviado: 213..232
|
24
|
+
res_cnab2: 233..239
|
@@ -0,0 +1,15 @@
|
|
1
|
+
banco: 0..2
|
2
|
+
lote: 3..6
|
3
|
+
registro: 7..7
|
4
|
+
res_cnab1: 8..16
|
5
|
+
qtd_registros: 17..22
|
6
|
+
qtd_titulos_simples: 23..28
|
7
|
+
valor_titulos_simples: 29..45
|
8
|
+
qtd_titulos_vinculada: 46..51
|
9
|
+
valor_titulos_simples: 52..68
|
10
|
+
qtd_titulos_caucionada: 69..74
|
11
|
+
valor_titulos_caucionada: 75..91
|
12
|
+
qtd_titulos_descontada: 92..97
|
13
|
+
valor_titulos_descontada: 98..114
|
14
|
+
num_aviso: 115..122
|
15
|
+
res_cnab3: 123..239
|
data/spec/cnab.txt
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
|
2
|
+
012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
|
3
|
+
0123456789012T4567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
|
4
|
+
0123456789012U4567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
|
5
|
+
0123456589012U4567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
|
6
|
+
0123456589012U4567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cnab::Definition do
|
4
|
+
describe "#initialize" do
|
5
|
+
it "should initialize a header_arquivo instance" do
|
6
|
+
Cnab::Definition.new('08.7').header_arquivo.should be_an_instance_of(Cnab::Definitions::HeaderArquivo)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should initialize a header_lote instance" do
|
10
|
+
Cnab::Definition.new('08.7').header_lote.should be_an_instance_of(Cnab::Definitions::HeaderLote)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should initialize a segmento_t instance" do
|
14
|
+
Cnab::Definition.new('08.7').segmento_t.should be_an_instance_of(Cnab::Definitions::SegmentoT)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should initialize a segmento_u instance" do
|
18
|
+
Cnab::Definition.new('08.7').segmento_u.should be_an_instance_of(Cnab::Definitions::SegmentoU)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should initialize a trailer_lote instance" do
|
22
|
+
Cnab::Definition.new('08.7').trailer_lote.should be_an_instance_of(Cnab::Definitions::TrailerLote)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should initialize a trailer_arquivo instance" do
|
26
|
+
Cnab::Definition.new('08.7').trailer_arquivo.should be_an_instance_of(Cnab::Definitions::TrailerArquivo)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cnab::Definitions::HeaderArquivo do
|
4
|
+
let(:object) { Object.new }
|
5
|
+
|
6
|
+
describe "#initialize" do
|
7
|
+
it "should load header_arquivo.yml" do
|
8
|
+
Cnab::Definitions::HeaderArquivo.new('08.7').instance_variable_get("@definition").should be_an_instance_of(Hash)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#method_missing" do
|
13
|
+
it "should return the value of the method as key in the hash" do
|
14
|
+
Cnab::Definitions::HeaderArquivo.new('08.7').banco.should == Range.new(0, 2)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cnab::Definitions::HeaderLote do
|
4
|
+
let(:object) { Object.new }
|
5
|
+
|
6
|
+
describe "#initialize" do
|
7
|
+
it "should load header_lote.yml" do
|
8
|
+
Cnab::Definitions::HeaderLote.new('08.7').instance_variable_get("@definition").should be_an_instance_of(Hash)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#method_missing" do
|
13
|
+
it "should return the value of the method as key in the hash" do
|
14
|
+
Cnab::Definitions::HeaderLote.new('08.7').banco.should == Range.new(0, 2)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cnab::Definitions::SegmentoT do
|
4
|
+
let(:object) { Object.new }
|
5
|
+
|
6
|
+
describe "#initialize" do
|
7
|
+
it "should load segmento_t.yml" do
|
8
|
+
Cnab::Definitions::SegmentoT.new('08.7').instance_variable_get("@definition").should be_an_instance_of(Hash)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#method_missing" do
|
13
|
+
it "should return the value of the method as key in the hash" do
|
14
|
+
Cnab::Definitions::SegmentoT.new('08.7').banco.should == Range.new(0, 2)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cnab::Definitions::SegmentoU do
|
4
|
+
let(:object) { Object.new }
|
5
|
+
|
6
|
+
describe "#initialize" do
|
7
|
+
it "should load segmento_u.yml" do
|
8
|
+
Cnab::Definitions::SegmentoU.new('08.7').instance_variable_get("@definition").should be_an_instance_of(Hash)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#method_missing" do
|
13
|
+
it "should return the value of the method as key in the hash" do
|
14
|
+
Cnab::Definitions::SegmentoU.new('08.7').banco.should == Range.new(0, 2)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cnab::Definitions::TrailerArquivo do
|
4
|
+
let(:object) { Object.new }
|
5
|
+
|
6
|
+
describe "#initialize" do
|
7
|
+
it "should load trailer_arquivo.yml" do
|
8
|
+
Cnab::Definitions::TrailerArquivo.new('08.7').instance_variable_get("@definition").should be_an_instance_of(Hash)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#method_missing" do
|
13
|
+
it "should return the value of the method as key in the hash" do
|
14
|
+
Cnab::Definitions::TrailerArquivo.new('08.7').banco.should == Range.new(0, 2)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cnab::Definitions::TrailerLote do
|
4
|
+
let(:object) { Object.new }
|
5
|
+
|
6
|
+
describe "#initialize" do
|
7
|
+
it "should load trailer_lote.yml" do
|
8
|
+
Cnab::Definitions::TrailerLote.new('08.7').instance_variable_get("@definition").should be_an_instance_of(Hash)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#method_missing" do
|
13
|
+
it "should return the value of the method as key in the hash" do
|
14
|
+
Cnab::Definitions::TrailerLote.new('08.7').banco.should == Range.new(0, 2)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,16 +1,20 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Cnab::Detalhe::SegmentoT do
|
4
|
+
before :each do
|
5
|
+
@definition = Cnab::Definitions::SegmentoT.new('08.7')
|
6
|
+
end
|
7
|
+
|
4
8
|
describe "#initialize" do
|
5
9
|
context "with a non valid line" do
|
6
10
|
it "should raise an error" do
|
7
|
-
lambda { Cnab::Detalhe::SegmentoT.new("12345") }.should raise_error(Cnab::Exceptions::LineNotParseable)
|
11
|
+
lambda { Cnab::Detalhe::SegmentoT.new("12345", @definition) }.should raise_error(Cnab::Exceptions::LineNotParseable)
|
8
12
|
end
|
9
13
|
end
|
10
14
|
|
11
15
|
context "with a valid line" do
|
12
16
|
before :each do
|
13
|
-
@segmento_t = Cnab::Detalhe::SegmentoT.new(LINE)
|
17
|
+
@segmento_t = Cnab::Detalhe::SegmentoT.new(LINE, @definition)
|
14
18
|
end
|
15
19
|
|
16
20
|
it "should set #banco" do
|
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Cnab::Detalhe::SegmentoTU do
|
4
|
-
let(:
|
5
|
-
let(:
|
4
|
+
let(:definition_t) { Cnab::Definitions::SegmentoT.new('08.7') }
|
5
|
+
let(:definition_u) { Cnab::Definitions::SegmentoU.new('08.7') }
|
6
|
+
let(:segmento_t) { Cnab::Detalhe::SegmentoT.new(LINE, definition_t) }
|
7
|
+
let(:segmento_u) { Cnab::Detalhe::SegmentoU.new(LINE, definition_u) }
|
6
8
|
|
7
9
|
describe "#method_missing" do
|
8
10
|
before :each do
|
@@ -1,16 +1,20 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Cnab::Detalhe::SegmentoU do
|
4
|
+
before :each do
|
5
|
+
@definition = Cnab::Definitions::SegmentoU.new('08.7')
|
6
|
+
end
|
7
|
+
|
4
8
|
describe "#initialize" do
|
5
9
|
context "with a non valid line" do
|
6
10
|
it "should raise an error" do
|
7
|
-
lambda { Cnab::Detalhe::SegmentoU.new("12345") }.should raise_error(Cnab::Exceptions::LineNotParseable)
|
11
|
+
lambda { Cnab::Detalhe::SegmentoU.new("12345", @definition) }.should raise_error(Cnab::Exceptions::LineNotParseable)
|
8
12
|
end
|
9
13
|
end
|
10
14
|
|
11
15
|
context "with a valid line" do
|
12
16
|
before :each do
|
13
|
-
@segmento_u = Cnab::Detalhe::SegmentoU.new(LINE)
|
17
|
+
@segmento_u = Cnab::Detalhe::SegmentoU.new(LINE, @definition)
|
14
18
|
end
|
15
19
|
|
16
20
|
it "should set #banco" do
|
data/spec/cnab/detalhe_spec.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Cnab::Detalhe do
|
4
|
+
let(:definition) { Cnab::Definition.new('08.7') }
|
5
|
+
|
4
6
|
describe "#parse" do
|
5
7
|
context "with a line of segmento U" do
|
6
8
|
before :each do
|
@@ -9,7 +11,7 @@ describe Cnab::Detalhe do
|
|
9
11
|
end
|
10
12
|
|
11
13
|
it "should return a instance of SegmentoU" do
|
12
|
-
Cnab::Detalhe.parse(@line).should be_an_instance_of(Cnab::Detalhe::SegmentoU)
|
14
|
+
Cnab::Detalhe.parse(@line, definition).should be_an_instance_of(Cnab::Detalhe::SegmentoU)
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
@@ -20,25 +22,25 @@ describe Cnab::Detalhe do
|
|
20
22
|
end
|
21
23
|
|
22
24
|
it "should return a instance of SegmentoT" do
|
23
|
-
Cnab::Detalhe.parse(@line).should be_an_instance_of(Cnab::Detalhe::SegmentoT)
|
25
|
+
Cnab::Detalhe.parse(@line, definition).should be_an_instance_of(Cnab::Detalhe::SegmentoT)
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
27
29
|
context "with a line of any other segmento" do
|
28
30
|
it "should raise an error" do
|
29
|
-
lambda { Cnab::Detalhe.parse(LINE) }.should raise_error(Cnab::Exceptions::SegmentNotImplemented)
|
31
|
+
lambda { Cnab::Detalhe.parse(LINE, definition) }.should raise_error(Cnab::Exceptions::SegmentNotImplemented)
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
34
36
|
describe "#merge" do
|
35
37
|
before :each do
|
36
|
-
|
37
|
-
|
38
|
+
@line = LINE.clone
|
39
|
+
@line[13] = "T"
|
38
40
|
end
|
39
41
|
|
40
42
|
it "should return a Cnab::Detalhe::SegmentoTU instance" do
|
41
|
-
Cnab::Detalhe.merge(
|
43
|
+
Cnab::Detalhe.merge(@line, @line, definition).should be_an_instance_of(Cnab::Detalhe::SegmentoTU)
|
42
44
|
end
|
43
45
|
end
|
44
46
|
end
|
@@ -1,16 +1,20 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Cnab::HeaderArquivo do
|
4
|
+
before :each do
|
5
|
+
@definition = Cnab::Definitions::HeaderArquivo.new('08.7')
|
6
|
+
end
|
7
|
+
|
4
8
|
context "with a non valid line" do
|
5
9
|
it "should raise an error" do
|
6
|
-
lambda { Cnab::HeaderArquivo.new("12345") }.should raise_error(Cnab::Exceptions::LineNotParseable)
|
10
|
+
lambda { Cnab::HeaderArquivo.new("12345", @definition) }.should raise_error(Cnab::Exceptions::LineNotParseable)
|
7
11
|
end
|
8
12
|
end
|
9
13
|
|
10
14
|
context "with a valid line" do
|
11
15
|
describe "#initialize" do
|
12
16
|
before :each do
|
13
|
-
@header_arquivo = Cnab::HeaderArquivo.new(LINE)
|
17
|
+
@header_arquivo = Cnab::HeaderArquivo.new(LINE, @definition)
|
14
18
|
end
|
15
19
|
|
16
20
|
it "should set #banco" do
|
@@ -1,16 +1,20 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Cnab::HeaderLote::Cobranca do
|
4
|
+
before :each do
|
5
|
+
@definition = Cnab::Definitions::HeaderLote.new('08.7')
|
6
|
+
end
|
7
|
+
|
4
8
|
describe "#initialize" do
|
5
9
|
context "with a non valid line" do
|
6
10
|
it "should raise an error" do
|
7
|
-
lambda { Cnab::HeaderLote::Cobranca.new("12345") }.should raise_error(Cnab::Exceptions::LineNotParseable)
|
11
|
+
lambda { Cnab::HeaderLote::Cobranca.new("12345", @definition) }.should raise_error(Cnab::Exceptions::LineNotParseable)
|
8
12
|
end
|
9
13
|
end
|
10
14
|
|
11
15
|
context "with a valid line" do
|
12
16
|
before :each do
|
13
|
-
@cobranca = Cnab::HeaderLote::Cobranca.new(LINE)
|
17
|
+
@cobranca = Cnab::HeaderLote::Cobranca.new(LINE, @definition)
|
14
18
|
end
|
15
19
|
|
16
20
|
it "should set #banco" do
|
@@ -1,16 +1,20 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Cnab::TrailerArquivo do
|
4
|
+
before :each do
|
5
|
+
@definition = Cnab::Definitions::TrailerArquivo.new('08.7')
|
6
|
+
end
|
7
|
+
|
4
8
|
describe "#initialize" do
|
5
9
|
context "with a non valid line" do
|
6
10
|
it "should raise an error" do
|
7
|
-
lambda { Cnab::TrailerArquivo.new("12345") }.should raise_error(Cnab::Exceptions::LineNotParseable)
|
11
|
+
lambda { Cnab::TrailerArquivo.new("12345", @definition) }.should raise_error(Cnab::Exceptions::LineNotParseable)
|
8
12
|
end
|
9
13
|
end
|
10
14
|
|
11
15
|
context "with a valid line" do
|
12
16
|
before :each do
|
13
|
-
@trailer_arquivo = Cnab::TrailerArquivo.new(LINE)
|
17
|
+
@trailer_arquivo = Cnab::TrailerArquivo.new(LINE, @definition)
|
14
18
|
end
|
15
19
|
|
16
20
|
it "should set #banco" do
|
data/spec/cnab_spec.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'fakefs'
|
3
2
|
|
4
3
|
describe Cnab do
|
5
4
|
describe "#parse" do
|
6
|
-
context "
|
5
|
+
context "withouth file" do
|
7
6
|
it "should raise an exception" do
|
8
7
|
lambda { Cnab.parse }.should raise_error Cnab::Exceptions::NoFileGiven
|
9
8
|
end
|
@@ -11,68 +10,38 @@ describe Cnab do
|
|
11
10
|
|
12
11
|
context "with a file" do
|
13
12
|
context "and merge equal false" do
|
14
|
-
before :each do
|
15
|
-
@line = LINE.clone
|
16
|
-
@line[13] = "T"
|
17
|
-
|
18
|
-
File.open("cnab.txt", 'w') do |f|
|
19
|
-
f.write(@line)
|
20
|
-
f.write(@line)
|
21
|
-
f.write(@line)
|
22
|
-
@line[7] = "5"
|
23
|
-
f.write(@line)
|
24
|
-
f.write(@line)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
13
|
it "should return a Retorno instance" do
|
29
|
-
Cnab.parse("cnab.txt").should be_an_instance_of(Cnab::Retorno)
|
14
|
+
Cnab.parse("spec/cnab.txt").should be_an_instance_of(Cnab::Retorno)
|
30
15
|
end
|
31
16
|
|
32
17
|
it "should return a HeaderArquivo instance" do
|
33
|
-
Cnab.parse("cnab.txt").header_arquivo.should be_an_instance_of(Cnab::HeaderArquivo)
|
18
|
+
Cnab.parse("spec/cnab.txt").header_arquivo.should be_an_instance_of(Cnab::HeaderArquivo)
|
34
19
|
end
|
35
20
|
|
36
21
|
it "should return a HeaderLote instance" do
|
37
|
-
Cnab.parse("cnab.txt").header_lote.should be_an_instance_of(Cnab::HeaderLote::Cobranca)
|
22
|
+
Cnab.parse("spec/cnab.txt").header_lote.should be_an_instance_of(Cnab::HeaderLote::Cobranca)
|
38
23
|
end
|
39
24
|
|
40
25
|
it "should return an array of detalhes" do
|
41
|
-
Cnab.parse("cnab.txt").detalhes.should be_an_instance_of(Array)
|
26
|
+
Cnab.parse("spec/cnab.txt").detalhes.should be_an_instance_of(Array)
|
42
27
|
end
|
43
28
|
|
44
29
|
it "should return an SegmentoT instance inside detalhes array" do
|
45
|
-
Cnab.parse("cnab.txt").detalhes.first.should be_an_instance_of(Cnab::Detalhe::SegmentoT)
|
30
|
+
Cnab.parse("spec/cnab.txt").detalhes.first.should be_an_instance_of(Cnab::Detalhe::SegmentoT)
|
46
31
|
end
|
47
32
|
|
48
33
|
it "should return a TrailerLote instance" do
|
49
|
-
Cnab.parse("cnab.txt").trailer_lote.should be_an_instance_of(Cnab::TrailerLote::Cobranca)
|
34
|
+
Cnab.parse("spec/cnab.txt").trailer_lote.should be_an_instance_of(Cnab::TrailerLote::Cobranca)
|
50
35
|
end
|
51
36
|
|
52
37
|
it "should return a TrailerArquivo instance" do
|
53
|
-
Cnab.parse("cnab.txt").trailer_arquivo.should be_an_instance_of(Cnab::TrailerArquivo)
|
38
|
+
Cnab.parse("spec/cnab.txt").trailer_arquivo.should be_an_instance_of(Cnab::TrailerArquivo)
|
54
39
|
end
|
55
40
|
end
|
56
41
|
|
57
42
|
context "and merge equal true" do
|
58
|
-
before :each do
|
59
|
-
@line = LINE.clone
|
60
|
-
|
61
|
-
File.open("cnab.txt", 'w') do |f|
|
62
|
-
f.write(@line)
|
63
|
-
f.write(@line)
|
64
|
-
@line[13] = "T"
|
65
|
-
f.write(@line)
|
66
|
-
@line[13] = "U"
|
67
|
-
f.write(@line)
|
68
|
-
@line[7] = "5"
|
69
|
-
f.write(@line)
|
70
|
-
f.write(@line)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
43
|
it "should return an SegmentoTU instance inside detalhes array" do
|
75
|
-
Cnab.parse("cnab.txt", true).detalhes.first.should be_an_instance_of(Cnab::Detalhe::SegmentoTU)
|
44
|
+
Cnab.parse("spec/cnab.txt", true).detalhes.first.should be_an_instance_of(Cnab::Detalhe::SegmentoTU)
|
76
45
|
end
|
77
46
|
end
|
78
47
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cnab
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-04-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
@@ -44,22 +44,6 @@ dependencies:
|
|
44
44
|
- - ! '>='
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0'
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: fakefs
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
|
-
requirements:
|
52
|
-
- - ! '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
type: :development
|
56
|
-
prerelease: false
|
57
|
-
version_requirements: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
|
-
requirements:
|
60
|
-
- - ! '>='
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: '0'
|
63
47
|
- !ruby/object:Gem::Dependency
|
64
48
|
name: coveralls
|
65
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +78,14 @@ files:
|
|
94
78
|
- Rakefile
|
95
79
|
- cnab.gemspec
|
96
80
|
- lib/cnab.rb
|
81
|
+
- lib/cnab/definition.rb
|
82
|
+
- lib/cnab/definitions.rb
|
83
|
+
- lib/cnab/definitions/header_arquivo.rb
|
84
|
+
- lib/cnab/definitions/header_lote.rb
|
85
|
+
- lib/cnab/definitions/segmento_t.rb
|
86
|
+
- lib/cnab/definitions/segmento_u.rb
|
87
|
+
- lib/cnab/definitions/trailer_arquivo.rb
|
88
|
+
- lib/cnab/definitions/trailer_lote.rb
|
97
89
|
- lib/cnab/detalhe.rb
|
98
90
|
- lib/cnab/detalhe/segmento_t.rb
|
99
91
|
- lib/cnab/detalhe/segmento_t_u.rb
|
@@ -111,6 +103,20 @@ files:
|
|
111
103
|
- lib/cnab/trailer_lote.rb
|
112
104
|
- lib/cnab/trailer_lote/cobranca.rb
|
113
105
|
- lib/cnab/version.rb
|
106
|
+
- lib/cnab/versions/08.7/header_arquivo.yml
|
107
|
+
- lib/cnab/versions/08.7/header_lote.yml
|
108
|
+
- lib/cnab/versions/08.7/segmento_t.yml
|
109
|
+
- lib/cnab/versions/08.7/segmento_u.yml
|
110
|
+
- lib/cnab/versions/08.7/trailer_arquivo.yml
|
111
|
+
- lib/cnab/versions/08.7/trailer_lote.yml
|
112
|
+
- spec/cnab.txt
|
113
|
+
- spec/cnab/definition_spec.rb
|
114
|
+
- spec/cnab/definitions/header_arquivo_spec.rb
|
115
|
+
- spec/cnab/definitions/header_lote_spec.rb
|
116
|
+
- spec/cnab/definitions/segmento_t_spec.rb
|
117
|
+
- spec/cnab/definitions/segmento_u_spec.rb
|
118
|
+
- spec/cnab/definitions/trailer_arquivo_spec.rb
|
119
|
+
- spec/cnab/definitions/trailer_lote_spec.rb
|
114
120
|
- spec/cnab/detalhe/segmento_t_spec.rb
|
115
121
|
- spec/cnab/detalhe/segmento_t_u_spec.rb
|
116
122
|
- spec/cnab/detalhe/segmento_u_spec.rb
|
@@ -135,7 +141,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
135
141
|
version: '0'
|
136
142
|
segments:
|
137
143
|
- 0
|
138
|
-
hash:
|
144
|
+
hash: 3361106697882866932
|
139
145
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
146
|
none: false
|
141
147
|
requirements:
|
@@ -144,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
150
|
version: '0'
|
145
151
|
segments:
|
146
152
|
- 0
|
147
|
-
hash:
|
153
|
+
hash: 3361106697882866932
|
148
154
|
requirements: []
|
149
155
|
rubyforge_project:
|
150
156
|
rubygems_version: 1.8.25
|
@@ -152,6 +158,14 @@ signing_key:
|
|
152
158
|
specification_version: 3
|
153
159
|
summary: It parse CNAB files
|
154
160
|
test_files:
|
161
|
+
- spec/cnab.txt
|
162
|
+
- spec/cnab/definition_spec.rb
|
163
|
+
- spec/cnab/definitions/header_arquivo_spec.rb
|
164
|
+
- spec/cnab/definitions/header_lote_spec.rb
|
165
|
+
- spec/cnab/definitions/segmento_t_spec.rb
|
166
|
+
- spec/cnab/definitions/segmento_u_spec.rb
|
167
|
+
- spec/cnab/definitions/trailer_arquivo_spec.rb
|
168
|
+
- spec/cnab/definitions/trailer_lote_spec.rb
|
155
169
|
- spec/cnab/detalhe/segmento_t_spec.rb
|
156
170
|
- spec/cnab/detalhe/segmento_t_u_spec.rb
|
157
171
|
- spec/cnab/detalhe/segmento_u_spec.rb
|