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.
@@ -10,46 +10,70 @@ describe Cnab do
10
10
  end
11
11
 
12
12
  context "with a file" do
13
- before :each do
14
- @line = "#{LINE}\n"
15
- @line[13] = "T"
16
-
17
- File.open("cnab.txt", 'w') do |f|
18
- f.write(@line)
19
- f.write(@line)
20
- f.write(@line)
21
- @line[7] = "5"
22
- f.write(@line)
23
- f.write(@line)
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
- it "should return a Retorno instance" do
28
- Cnab.parse("cnab.txt").should be_an_instance_of(Cnab::Retorno)
29
- end
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
- it "should return a HeaderArquivo instance" do
32
- Cnab.parse("cnab.txt").header_arquivo.should be_an_instance_of(Cnab::HeaderArquivo)
33
- end
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
- it "should return a HeaderLote instance" do
36
- Cnab.parse("cnab.txt").header_lote.should be_an_instance_of(Cnab::HeaderLote::Cobranca)
37
- end
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
- it "should return an array of detalhes" do
40
- Cnab.parse("cnab.txt").detalhes.should be_an_instance_of(Array)
41
- end
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
- it "should return an SegmentoT instance inside detalhes array" do
44
- Cnab.parse("cnab.txt").detalhes.first.should be_an_instance_of(Cnab::Detalhe::SegmentoT)
45
- end
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
- it "should return a TrailerLote instance" do
48
- Cnab.parse("cnab.txt").trailer_lote.should be_an_instance_of(Cnab::TrailerLote::Cobranca)
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
- it "should return a TrailerArquivo instance" do
52
- Cnab.parse("cnab.txt").trailer_arquivo.should be_an_instance_of(Cnab::TrailerArquivo)
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
@@ -5,4 +5,4 @@ Coveralls.wear!
5
5
 
6
6
  require File.dirname(__FILE__) + "/../lib/cnab"
7
7
 
8
- LINE = (0..239).to_a.map { |i| i = i % 10 }.join("")
8
+ LINE = (0..239).to_a.map { |i| i %= 10 }.join("") + "\r\n"
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.1.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-26 00:00:00.000000000 Z
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