cnab 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +18 -2
- data/lib/cnab.rb +6 -2
- data/lib/cnab/detalhe.rb +5 -0
- data/lib/cnab/detalhe/segmento_t.rb +31 -29
- data/lib/cnab/detalhe/segmento_t_u.rb +22 -0
- data/lib/cnab/detalhe/segmento_u.rb +26 -24
- data/lib/cnab/exceptions.rb +1 -0
- data/lib/cnab/exceptions/line_not_parseable.rb +9 -0
- data/lib/cnab/header_arquivo.rb +26 -24
- data/lib/cnab/header_lote/cobranca.rb +25 -23
- data/lib/cnab/helper.rb +13 -1
- data/lib/cnab/trailer_arquivo.rb +10 -8
- data/lib/cnab/trailer_lote/cobranca.rb +17 -15
- data/lib/cnab/version.rb +1 -1
- data/spec/cnab/detalhe/segmento_t_spec.rb +97 -89
- data/spec/cnab/detalhe/segmento_t_u_spec.rb +24 -0
- data/spec/cnab/detalhe/segmento_u_spec.rb +105 -97
- data/spec/cnab/detalhe_spec.rb +24 -3
- data/spec/cnab/header_arquivo_spec.rb +103 -95
- data/spec/cnab/header_lote/cobranca_spec.rb +79 -71
- data/spec/cnab/trailer_arquivo_spec.rb +34 -26
- data/spec/cnab_spec.rb +55 -31
- data/spec/spec_helper.rb +1 -1
- metadata +12 -2
data/spec/cnab_spec.rb
CHANGED
@@ -10,46 +10,70 @@ describe Cnab do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
context "with a file" do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
13
|
+
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
|
24
26
|
end
|
25
|
-
end
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
it "should return a Retorno instance" do
|
29
|
+
Cnab.parse("cnab.txt").should be_an_instance_of(Cnab::Retorno)
|
30
|
+
end
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
it "should return a HeaderArquivo instance" do
|
33
|
+
Cnab.parse("cnab.txt").header_arquivo.should be_an_instance_of(Cnab::HeaderArquivo)
|
34
|
+
end
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
it "should return a HeaderLote instance" do
|
37
|
+
Cnab.parse("cnab.txt").header_lote.should be_an_instance_of(Cnab::HeaderLote::Cobranca)
|
38
|
+
end
|
38
39
|
|
39
|
-
|
40
|
-
|
41
|
-
|
40
|
+
it "should return an array of detalhes" do
|
41
|
+
Cnab.parse("cnab.txt").detalhes.should be_an_instance_of(Array)
|
42
|
+
end
|
42
43
|
|
43
|
-
|
44
|
-
|
45
|
-
|
44
|
+
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)
|
46
|
+
end
|
46
47
|
|
47
|
-
|
48
|
-
|
48
|
+
it "should return a TrailerLote instance" do
|
49
|
+
Cnab.parse("cnab.txt").trailer_lote.should be_an_instance_of(Cnab::TrailerLote::Cobranca)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should return a TrailerArquivo instance" do
|
53
|
+
Cnab.parse("cnab.txt").trailer_arquivo.should be_an_instance_of(Cnab::TrailerArquivo)
|
54
|
+
end
|
49
55
|
end
|
50
56
|
|
51
|
-
|
52
|
-
|
57
|
+
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
|
+
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)
|
76
|
+
end
|
53
77
|
end
|
54
78
|
end
|
55
79
|
end
|
data/spec/spec_helper.rb
CHANGED
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.2.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-03-
|
13
|
+
date: 2013-03-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
@@ -96,8 +96,10 @@ files:
|
|
96
96
|
- lib/cnab.rb
|
97
97
|
- lib/cnab/detalhe.rb
|
98
98
|
- lib/cnab/detalhe/segmento_t.rb
|
99
|
+
- lib/cnab/detalhe/segmento_t_u.rb
|
99
100
|
- lib/cnab/detalhe/segmento_u.rb
|
100
101
|
- lib/cnab/exceptions.rb
|
102
|
+
- lib/cnab/exceptions/line_not_parseable.rb
|
101
103
|
- lib/cnab/exceptions/no_file_given.rb
|
102
104
|
- lib/cnab/exceptions/segment_not_implemented.rb
|
103
105
|
- lib/cnab/header_arquivo.rb
|
@@ -110,6 +112,7 @@ files:
|
|
110
112
|
- lib/cnab/trailer_lote/cobranca.rb
|
111
113
|
- lib/cnab/version.rb
|
112
114
|
- spec/cnab/detalhe/segmento_t_spec.rb
|
115
|
+
- spec/cnab/detalhe/segmento_t_u_spec.rb
|
113
116
|
- spec/cnab/detalhe/segmento_u_spec.rb
|
114
117
|
- spec/cnab/detalhe_spec.rb
|
115
118
|
- spec/cnab/header_arquivo_spec.rb
|
@@ -130,12 +133,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
130
133
|
- - ! '>='
|
131
134
|
- !ruby/object:Gem::Version
|
132
135
|
version: '0'
|
136
|
+
segments:
|
137
|
+
- 0
|
138
|
+
hash: -1331239976461434073
|
133
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
140
|
none: false
|
135
141
|
requirements:
|
136
142
|
- - ! '>='
|
137
143
|
- !ruby/object:Gem::Version
|
138
144
|
version: '0'
|
145
|
+
segments:
|
146
|
+
- 0
|
147
|
+
hash: -1331239976461434073
|
139
148
|
requirements: []
|
140
149
|
rubyforge_project:
|
141
150
|
rubygems_version: 1.8.25
|
@@ -144,6 +153,7 @@ specification_version: 3
|
|
144
153
|
summary: It parse CNAB files
|
145
154
|
test_files:
|
146
155
|
- spec/cnab/detalhe/segmento_t_spec.rb
|
156
|
+
- spec/cnab/detalhe/segmento_t_u_spec.rb
|
147
157
|
- spec/cnab/detalhe/segmento_u_spec.rb
|
148
158
|
- spec/cnab/detalhe_spec.rb
|
149
159
|
- spec/cnab/header_arquivo_spec.rb
|