cnab240 0.0.13 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -68,9 +68,9 @@ module Cnab240
68
68
  def find_header_arquivo(line, line_number = -1)
69
69
  arquivos << Cnab240::Arquivo::Arquivo.new
70
70
  case line[RANGE_LAYOUT_ARQUIVO]
71
- # when '080'
72
- # arquivos.last.versao = 'V80'
73
- # arquivos.last.header = Cnab240::V80::Arquivo::Header.read(line)
71
+ # when '080'
72
+ # arquivos.last.versao = 'V80'
73
+ # arquivos.last.header = Cnab240::V80::Arquivo::Header.read(line)
74
74
  when '085'
75
75
  arquivos.last.versao = 'V86'
76
76
  arquivos.last.header = Cnab240::V86::Arquivo::Header.read(line)
@@ -95,6 +95,10 @@ module Cnab240
95
95
 
96
96
  def find_header_lote(line, line_number = -1)
97
97
  case line[RANGE_HEADER_LOTE]
98
+ when '080'
99
+ arquivos.last.lotes << Cnab240::Lote.new(:operacao => :pagamento, :tipo => :none, :versao => 'V80') do |l|
100
+ l.header = Cnab240::V80::Pagamentos::Header.read(line)
101
+ end
98
102
  when '030'
99
103
  case arquivos.last.versao
100
104
  when 'V80'
@@ -27,9 +27,11 @@ module Cnab240
27
27
  yield self if block_given?
28
28
  end
29
29
 
30
- def read_segmento(s, line)
31
- segmentos << segmento.read(line)
32
- end
30
+ def read_segmento(s, line)
31
+ versao = arquivo.versao unless arquivo.nil?
32
+ versao ||= @versao
33
+ segmentos << seg = eval("Cnab240::#{versao}::Segmento#{s.to_s.upcase}.read(line)")
34
+ end
33
35
 
34
36
  def <<(s)
35
37
  versao = arquivo.versao unless arquivo.nil?
@@ -1,4 +1,4 @@
1
1
  module Cnab240
2
- VERSION = "0.0.13"
2
+ VERSION = "0.0.15"
3
3
  end
4
4
 
data/spec/hom/hom_spec.rb CHANGED
@@ -42,4 +42,24 @@ describe "HomSpec" do
42
42
  pagamento.save_to_file("spec/tmp/itau46.rem")
43
43
  end
44
44
 
45
+ it "deve carregar arquivo de retorno" do
46
+ arquivo_read = Cnab240::Arquivo::Arquivo.load_from_file("spec/hom/retorno/SB22112AIT.ret")[0]
47
+
48
+ arquivo_read.lotes.length.should be 1
49
+
50
+ arquivo_read.lotes.each_with_index do |lote_read, i|
51
+ lote_read.header.empresa_nome.equal? 'REDE DE CONVENIOS DO BRASIL '
52
+ end
53
+
54
+
55
+ arquivo_read = Cnab240::Arquivo::Arquivo.load_from_file("spec/hom/retorno/SB23112AIT.ret")[0]
56
+
57
+ arquivo_read.lotes.length.should be 1
58
+
59
+ arquivo_read.lotes.each_with_index do |lote_read, i|
60
+ lote_read.header.empresa_nome.equal? 'REDE DE CONVENIOS DO BRASIL '
61
+ end
62
+
63
+ end
64
+
45
65
  end
metadata CHANGED
@@ -1,55 +1,61 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: cnab240
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.13
3
+ version: !ruby/object:Gem::Version
4
+ hash: 1
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 15
10
+ version: 0.0.15
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Eduardo Mourao
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-11-12 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: rspec
16
- requirement: !ruby/object:Gem::Requirement
17
+
18
+ date: 2012-11-26 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ version_requirements: &id001 !ruby/object:Gem::Requirement
17
23
  none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :development
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ hash: 3
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ requirement: *id001
23
32
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
33
+ name: rspec
34
+ type: :development
35
+ - !ruby/object:Gem::Dependency
36
+ version_requirements: &id002 !ruby/object:Gem::Requirement
25
37
  none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ hash: 3
42
+ segments:
43
+ - 0
44
+ version: "0"
45
+ requirement: *id002
46
+ prerelease: false
31
47
  name: bindata
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
38
48
  type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
49
  description: Formato CNAB 240.
47
- email:
50
+ email:
48
51
  - eduardo.a20@gmail.com
49
52
  executables: []
53
+
50
54
  extensions: []
55
+
51
56
  extra_rdoc_files: []
52
- files:
57
+
58
+ files:
53
59
  - .gitignore
54
60
  - .rspec
55
61
  - .travis.yml
@@ -160,37 +166,41 @@ files:
160
166
  - spec/segmentos/v86/segmento_z_spec.rb
161
167
  - spec/spec_helper.rb
162
168
  - spec/tmp/.gitkeep
163
- homepage: ''
169
+ has_rdoc: true
170
+ homepage: ""
164
171
  licenses: []
172
+
165
173
  post_install_message:
166
174
  rdoc_options: []
167
- require_paths:
175
+
176
+ require_paths:
168
177
  - lib
169
- required_ruby_version: !ruby/object:Gem::Requirement
178
+ required_ruby_version: !ruby/object:Gem::Requirement
170
179
  none: false
171
- requirements:
172
- - - ! '>='
173
- - !ruby/object:Gem::Version
174
- version: '0'
175
- segments:
180
+ requirements:
181
+ - - ">="
182
+ - !ruby/object:Gem::Version
183
+ hash: 3
184
+ segments:
176
185
  - 0
177
- hash: 2879206540769969001
178
- required_rubygems_version: !ruby/object:Gem::Requirement
186
+ version: "0"
187
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
188
  none: false
180
- requirements:
181
- - - ! '>='
182
- - !ruby/object:Gem::Version
183
- version: '0'
184
- segments:
189
+ requirements:
190
+ - - ">="
191
+ - !ruby/object:Gem::Version
192
+ hash: 3
193
+ segments:
185
194
  - 0
186
- hash: 2879206540769969001
195
+ version: "0"
187
196
  requirements: []
197
+
188
198
  rubyforge_project: cnab240
189
- rubygems_version: 1.8.24
199
+ rubygems_version: 1.5.3
190
200
  signing_key:
191
201
  specification_version: 3
192
202
  summary: Formato CNAB 240.
193
- test_files:
203
+ test_files:
194
204
  - spec/arquivo/arquivo_spec.rb
195
205
  - spec/arquivo/v40/header_spec.rb
196
206
  - spec/arquivo/v40/trailer_spec.rb