ofx 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -9,25 +9,30 @@ JEWEL = Jeweler::Tasks.new do |gem|
9
9
  gem.summary = "A simple OFX (Open Financial Exchange) parser built on top of Nokogiri. Currently supports OFX 1.0.2."
10
10
  gem.description = <<-TXT
11
11
  A simple OFX (Open Financial Exchange) parser built on top of Nokogiri. Currently supports OFX 1.0.2.
12
+
13
+ Usage:
14
+
15
+ OFX("sample.ofx") do |ofx|
16
+ p ofx
17
+ end
12
18
  TXT
13
-
19
+
14
20
  gem.authors = ["Nando Vieira"]
15
21
  gem.email = "fnando.vieira@gmail.com"
16
22
  gem.homepage = "http://github.com/fnando/ofx"
17
-
23
+
18
24
  gem.has_rdoc = false
19
- gem.files = %w(Rakefile ofx.gemspec VERSION README.markdown) + Dir["{bin,lib,spec}/**/*"]
20
-
25
+ gem.files = %w(Rakefile ofx.gemspec README.markdown) + Dir["{lib,spec}/**/*"]
26
+
21
27
  gem.add_dependency "nokogiri"
22
28
  end
23
29
 
24
- desc "Build and install the gem"
25
30
  desc "Generate gemspec and build gem"
26
31
  task :build_gem do
27
- File.open("VERSION", "w+") {|f| f << OFX::Version::STRING }
28
-
29
32
  Rake::Task["gemspec"].invoke
30
33
  Rake::Task["build"].invoke
31
34
  end
32
35
 
36
+ Jeweler::GemcutterTasks.new
37
+
33
38
  Spec::Rake::SpecTask.new {|t| t.spec_opts = ["-c", "-f s"] }
data/lib/ofx/errors.rb ADDED
@@ -0,0 +1,3 @@
1
+ module OFX
2
+ class UnsupportedVersionError < StandardError; end
3
+ end
data/lib/ofx/parser.rb CHANGED
@@ -10,10 +10,11 @@ module OFX
10
10
  @content = open_resource(resource).read
11
11
  @headers, @body = prepare(content)
12
12
 
13
- @parser = case @headers["VERSION"]
14
- when "102"; OFX::Parser::OFX102.new(:headers => headers, :body => body)
13
+ case @headers["VERSION"]
14
+ when "102" then
15
+ @parser = OFX::Parser::OFX102.new(:headers => headers, :body => body)
15
16
  else
16
- raise OFX::Parser::InvalidVersion
17
+ raise OFX::UnsupportedVersionError
17
18
  end
18
19
  end
19
20
 
data/lib/ofx/version.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  module OFX
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 1
5
- PATCH = 0
4
+ MINOR = 2
5
+ PATCH = 1
6
6
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
7
  end
8
8
  end
data/lib/ofx.rb CHANGED
@@ -1,12 +1,7 @@
1
1
  require "open-uri"
2
+ require "nokogiri"
2
3
 
3
- begin
4
- require "nokogiri"
5
- rescue LoadError => e
6
- require "rubygems"
7
- require "nokogiri"
8
- end
9
-
4
+ require "ofx/errors"
10
5
  require "ofx/parser"
11
6
  require "ofx/parser/ofx102"
12
7
  require "ofx/foundation"
data/ofx.gemspec CHANGED
@@ -1,16 +1,22 @@
1
1
  # Generated by jeweler
2
- # DO NOT EDIT THIS FILE
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ofx}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Nando Vieira"]
12
- s.date = %q{2009-11-13}
12
+ s.date = %q{2010-03-09}
13
13
  s.description = %q{A simple OFX (Open Financial Exchange) parser built on top of Nokogiri. Currently supports OFX 1.0.2.
14
+
15
+ Usage:
16
+
17
+ OFX("sample.ofx") do |ofx|
18
+ p ofx
19
+ end
14
20
  }
15
21
  s.email = %q{fnando.vieira@gmail.com}
16
22
  s.extra_rdoc_files = [
@@ -19,16 +25,17 @@ Gem::Specification.new do |s|
19
25
  s.files = [
20
26
  "README.markdown",
21
27
  "Rakefile",
22
- "VERSION",
23
28
  "lib/ofx.rb",
24
29
  "lib/ofx/account.rb",
25
30
  "lib/ofx/balance.rb",
31
+ "lib/ofx/errors.rb",
26
32
  "lib/ofx/foundation.rb",
27
33
  "lib/ofx/parser.rb",
28
34
  "lib/ofx/parser/ofx102.rb",
29
35
  "lib/ofx/transaction.rb",
30
36
  "lib/ofx/version.rb",
31
37
  "ofx.gemspec",
38
+ "spec/fixtures/invalid_version.ofx",
32
39
  "spec/fixtures/sample.ofx",
33
40
  "spec/ofx/account_spec.rb",
34
41
  "spec/ofx/ofx102_spec.rb",
@@ -37,10 +44,11 @@ Gem::Specification.new do |s|
37
44
  "spec/ofx/transaction_spec.rb",
38
45
  "spec/spec_helper.rb"
39
46
  ]
47
+ s.has_rdoc = false
40
48
  s.homepage = %q{http://github.com/fnando/ofx}
41
49
  s.rdoc_options = ["--charset=UTF-8"]
42
50
  s.require_paths = ["lib"]
43
- s.rubygems_version = %q{1.3.5}
51
+ s.rubygems_version = %q{1.3.6}
44
52
  s.summary = %q{A simple OFX (Open Financial Exchange) parser built on top of Nokogiri. Currently supports OFX 1.0.2.}
45
53
  s.test_files = [
46
54
  "spec/ofx/account_spec.rb",
@@ -64,3 +72,4 @@ Gem::Specification.new do |s|
64
72
  s.add_dependency(%q<nokogiri>, [">= 0"])
65
73
  end
66
74
  end
75
+
@@ -0,0 +1,308 @@
1
+
2
+
3
+ OFXHEADER:100
4
+ DATA:OFXSGML
5
+ VERSION:200
6
+ SECURITY:NONE
7
+ ENCODING:USASCII
8
+ CHARSET:1252
9
+ COMPRESSION:NONE
10
+ OLDFILEUID:NONE
11
+ NEWFILEUID:NONE
12
+
13
+ <OFX>
14
+ <SIGNONMSGSRSV1>
15
+ <SONRS>
16
+ <STATUS>
17
+ <CODE>0
18
+ <SEVERITY>INFO
19
+ </STATUS>
20
+ <DTSERVER>20091101192253
21
+ <LANGUAGE>POR
22
+ </SONRS>
23
+ </SIGNONMSGSRSV1>
24
+ <BANKMSGSRSV1>
25
+ <STMTTRNRS>
26
+ <TRNUID>1
27
+ <STATUS>
28
+ <CODE>0
29
+ <SEVERITY>INFO
30
+ </STATUS>
31
+ <STMTRS>
32
+ <CURDEF>BRL
33
+ <BANKACCTFROM>
34
+ <BANKID>0356
35
+ <ACCTID>03227113109
36
+ <ACCTTYPE>CHECKING
37
+ </BANKACCTFROM>
38
+ <BANKTRANLIST>
39
+ <DTSTART>20091009080000
40
+ <DTEND>20091103080000
41
+ <STMTTRN>
42
+ <TRNTYPE>DEBIT
43
+ <DTPOSTED>20091009080000
44
+ <TRNAMT>-35.34
45
+ <FITID>200910091
46
+ <CHECKNUM>0001223
47
+ <MEMO>COMPRA VISA ELECTRON
48
+ </STMTTRN><STMTTRN>
49
+ <TRNTYPE>CREDIT
50
+ <DTPOSTED>20091016080000
51
+ <TRNAMT>60.39
52
+ <FITID>200910162
53
+ <CHECKNUM>0880136
54
+ <MEMO>DEPOSITO POUP.CORRENTE
55
+ </STMTTRN>
56
+
57
+ <STMTTRN>
58
+ <TRNTYPE>OTHER</TRNTYPE>
59
+ <DTPOSTED>20091019120000[-3:BRT]</DTPOSTED>
60
+ <TRNAMT>-148.40</TRNAMT>
61
+ <FITID>200910191148400</FITID>
62
+ <CHECKNUM>000000101901</CHECKNUM>
63
+ <REFNUM>101.901</REFNUM>
64
+ <PAYEE>Pagto conta telefone</PAYEE>
65
+ <MEMO>Pagto conta telefone</MEMO>
66
+ </STMTTRN>
67
+
68
+ <STMTTRN>
69
+ <TRNTYPE>DEBIT
70
+ <DTPOSTED>20091013080000
71
+ <TRNAMT>-126.13
72
+ <FITID>200910131
73
+ <CHECKNUM>0001511
74
+ <MEMO>TITULO COBRANCA-IB
75
+ </STMTTRN><STMTTRN>
76
+ <TRNTYPE>DEBIT
77
+ <DTPOSTED>20091013080000
78
+ <TRNAMT>-232.23
79
+ <FITID>200910132
80
+ <CHECKNUM>0001511
81
+ <MEMO>TITULO COBRANCA-IB
82
+ </STMTTRN><STMTTRN>
83
+ <TRNTYPE>DEBIT
84
+ <DTPOSTED>20091013080000
85
+ <TRNAMT>-501.24
86
+ <FITID>200910133
87
+ <CHECKNUM>0001511
88
+ <MEMO>TITULO COBRANCA-IB
89
+ </STMTTRN><STMTTRN>
90
+ <TRNTYPE>DEBIT
91
+ <DTPOSTED>20091013080000
92
+ <TRNAMT>-719.03
93
+ <FITID>200910134
94
+ <CHECKNUM>0001511
95
+ <MEMO>TITULO COBRANCA-IB
96
+ </STMTTRN><STMTTRN>
97
+ <TRNTYPE>DEBIT
98
+ <DTPOSTED>20091013080000
99
+ <TRNAMT>-90.75
100
+ <FITID>200910135
101
+ <CHECKNUM>0001223
102
+ <MEMO>COMPRA VISA ELECTRON
103
+ </STMTTRN><STMTTRN>
104
+ <TRNTYPE>DEBIT
105
+ <DTPOSTED>20091013080000
106
+ <TRNAMT>-49.80
107
+ <FITID>200910136
108
+ <CHECKNUM>0001223
109
+ <MEMO>COMPRA VISA ELECTRON
110
+ </STMTTRN><STMTTRN>
111
+ <TRNTYPE>DEBIT
112
+ <DTPOSTED>20091013080000
113
+ <TRNAMT>-219.90
114
+ <FITID>200910137
115
+ <CHECKNUM>0001223
116
+ <MEMO>COMPRA VISA ELECTRON
117
+ </STMTTRN><STMTTRN>
118
+ <TRNTYPE>DEBIT
119
+ <DTPOSTED>20091013080000
120
+ <TRNAMT>-54.61
121
+ <FITID>200910138
122
+ <CHECKNUM>0001223
123
+ <MEMO>COMPRA VISA ELECTRON
124
+ </STMTTRN><STMTTRN>
125
+ <TRNTYPE>DEBIT
126
+ <DTPOSTED>20091013080000
127
+ <TRNAMT>-38.57
128
+ <FITID>200910139
129
+ <CHECKNUM>0002208
130
+ <MEMO>PAGTO CONTA TELEFONE -RIB
131
+ </STMTTRN><STMTTRN>
132
+ <TRNTYPE>DEBIT
133
+ <DTPOSTED>20091013080000
134
+ <TRNAMT>-119.40
135
+ <FITID>2009101310
136
+ <CHECKNUM>0002209
137
+ <MEMO>CONTA DE LUZ -RIB
138
+ </STMTTRN><STMTTRN>
139
+ <TRNTYPE>DEBIT
140
+ <DTPOSTED>20091013080000
141
+ <TRNAMT>-34.69
142
+ <FITID>2009101311
143
+ <CHECKNUM>0002208
144
+ <MEMO>PAGTO CONTA TELEFONE -RIB
145
+ </STMTTRN><STMTTRN>
146
+ <TRNTYPE>DEBIT
147
+ <DTPOSTED>20091013080000
148
+ <TRNAMT>-35.07
149
+ <FITID>2009101312
150
+ <CHECKNUM>0002231
151
+ <MEMO>IPTU / TAXAS SP -RIB
152
+ </STMTTRN><STMTTRN>
153
+ <TRNTYPE>DEBIT
154
+ <DTPOSTED>20091013080000
155
+ <TRNAMT>-259.10
156
+ <FITID>2009101313
157
+ <CHECKNUM>0001085
158
+ <MEMO>PGTO NET
159
+ </STMTTRN><STMTTRN>
160
+ <TRNTYPE>DEBIT
161
+ <DTPOSTED>20091013080000
162
+ <TRNAMT>-202.84
163
+ <FITID>2009101314
164
+ <CHECKNUM>0002606
165
+ <MEMO>PARC RC EXCLUSIVO 12
166
+ </STMTTRN><STMTTRN>
167
+ <TRNTYPE>DEBIT
168
+ <DTPOSTED>20091013080000
169
+ <TRNAMT>-272.77
170
+ <FITID>2009101315
171
+ <CHECKNUM>0002606
172
+ <MEMO>PARC RC EXCLUSIVO 08
173
+ </STMTTRN><STMTTRN>
174
+ <TRNTYPE>DEBIT
175
+ <DTPOSTED>20091014080000
176
+ <TRNAMT>-80.00
177
+ <FITID>200910141
178
+ <CHECKNUM>0010991
179
+ <MEMO>CHEQUE COMPENSADO
180
+ </STMTTRN><STMTTRN>
181
+ <TRNTYPE>DEBIT
182
+ <DTPOSTED>20091014080000
183
+ <TRNAMT>-177.00
184
+ <FITID>200910142
185
+ <CHECKNUM>0010986
186
+ <MEMO>CHEQUE COMPENSADO
187
+ </STMTTRN><STMTTRN>
188
+ <TRNTYPE>DEBIT
189
+ <DTPOSTED>20091014080000
190
+ <TRNAMT>-386.00
191
+ <FITID>200910143
192
+ <CHECKNUM>0011063
193
+ <MEMO>CHEQUE COMPENSADO
194
+ </STMTTRN><STMTTRN>
195
+ <TRNTYPE>DEBIT
196
+ <DTPOSTED>20091014080000
197
+ <TRNAMT>-12.19
198
+ <FITID>200910144
199
+ <CHECKNUM>0001223
200
+ <MEMO>COMPRA VISA ELECTRON
201
+ </STMTTRN><STMTTRN>
202
+ <TRNTYPE>DEBIT
203
+ <DTPOSTED>20091015080000
204
+ <TRNAMT>-41.00
205
+ <FITID>200910151
206
+ <CHECKNUM>0011064
207
+ <MEMO>CHEQUE COMPENSADO
208
+ </STMTTRN><STMTTRN>
209
+ <TRNTYPE>DEBIT
210
+ <DTPOSTED>20091016080000
211
+ <TRNAMT>-63.00
212
+ <FITID>200910161
213
+ <CHECKNUM>0010856
214
+ <MEMO>CHEQUE COMPENSADO
215
+ </STMTTRN><STMTTRN>
216
+ <TRNTYPE>DEBIT
217
+ <DTPOSTED>20091019080000
218
+ <TRNAMT>-51.00
219
+ <FITID>200910191
220
+ <CHECKNUM>0011065
221
+ <MEMO>CHEQUE COMPENSADO
222
+ </STMTTRN><STMTTRN>
223
+ <TRNTYPE>DEBIT
224
+ <DTPOSTED>20091019080000
225
+ <TRNAMT>-23.81
226
+ <FITID>200910192
227
+ <CHECKNUM>0001203
228
+ <MEMO>ASSINATURA ABRIL
229
+ </STMTTRN><STMTTRN>
230
+ <TRNTYPE>DEBIT
231
+ <DTPOSTED>20091020080000
232
+ <TRNAMT>-15.50
233
+ <FITID>200910201
234
+ <CHECKNUM>0001223
235
+ <MEMO>COMPRA VISA ELECTRON
236
+ </STMTTRN><STMTTRN>
237
+ <TRNTYPE>DEBIT
238
+ <DTPOSTED>20091021080000
239
+ <TRNAMT>-132.00
240
+ <FITID>200910211
241
+ <CHECKNUM>0011023
242
+ <MEMO>CHEQUE COMPENSADO
243
+ </STMTTRN><STMTTRN>
244
+ <TRNTYPE>CREDIT
245
+ <DTPOSTED>20091022080000
246
+ <TRNAMT>600.00
247
+ <FITID>200910221
248
+ <CHECKNUM>0001433
249
+ <MEMO>DOC REM 216.397.168-66
250
+ </STMTTRN><STMTTRN>
251
+ <TRNTYPE>DEBIT
252
+ <DTPOSTED>20091022080000
253
+ <TRNAMT>-22.40
254
+ <FITID>200910222
255
+ <CHECKNUM>0001223
256
+ <MEMO>COMPRA VISA ELECTRON
257
+ </STMTTRN><STMTTRN>
258
+ <TRNTYPE>DEBIT
259
+ <DTPOSTED>20091022080000
260
+ <TRNAMT>-73.16
261
+ <FITID>200910223
262
+ <CHECKNUM>0001223
263
+ <MEMO>COMPRA VISA ELECTRON
264
+ </STMTTRN><STMTTRN>
265
+ <TRNTYPE>DEBIT
266
+ <DTPOSTED>20091023080000
267
+ <TRNAMT>-61.36
268
+ <FITID>200910231
269
+ <CHECKNUM>0000292
270
+ <MEMO>CONTA AGUA/ESGOTO
271
+ </STMTTRN><STMTTRN>
272
+ <TRNTYPE>DEBIT
273
+ <DTPOSTED>20091026080000
274
+ <TRNAMT>-96.00
275
+ <FITID>200910261
276
+ <CHECKNUM>0002212
277
+ <MEMO>PAGTO FATURA REALVISA-RIB
278
+ </STMTTRN><STMTTRN>
279
+ <TRNTYPE>DEBIT
280
+ <DTPOSTED>20091030080000
281
+ <TRNAMT>-67.75
282
+ <FITID>200910301
283
+ <CHECKNUM>0011061
284
+ <MEMO>CHEQUE COMPENSADO
285
+ </STMTTRN><STMTTRN>
286
+ <TRNTYPE>DEBIT
287
+ <DTPOSTED>20091030080000
288
+ <TRNAMT>-25.88
289
+ <FITID>200910302
290
+ <CHECKNUM>0001223
291
+ <MEMO>COMPRA VISA ELECTRON
292
+ </STMTTRN><STMTTRN>
293
+ <TRNTYPE>DEBIT
294
+ <DTPOSTED>20091103080000
295
+ <TRNAMT>-89.03
296
+ <FITID>200911031
297
+ <CHECKNUM>0001223
298
+ <MEMO>COMPRA VISA ELECTRON
299
+ </STMTTRN>
300
+ </BANKTRANLIST>
301
+ <LEDGERBAL>
302
+ <BALAMT>598.44
303
+ <DTASOF>20091101
304
+ </LEDGERBAL>
305
+ </STMTRS>
306
+ </STMTTRNRS>
307
+ </BANKMSGSRSV1>
308
+ </OFX>
@@ -30,6 +30,12 @@ describe OFX::Parser do
30
30
  @ofx.body.should_not be_nil
31
31
  end
32
32
 
33
+ it "should raise exception when trying to parse an unsupported OFX version" do
34
+ lambda {
35
+ OFX::Parser::Base.new("spec/fixtures/invalid_version.ofx")
36
+ }.should raise_error(OFX::UnsupportedVersionError)
37
+ end
38
+
33
39
  describe "headers" do
34
40
  it "should have OFXHEADER" do
35
41
  @ofx.headers["OFXHEADER"].should == "100"
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ofx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 2
8
+ - 1
9
+ version: 0.2.1
5
10
  platform: ruby
6
11
  authors:
7
12
  - Nando Vieira
@@ -9,21 +14,29 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2009-11-13 00:00:00 -02:00
17
+ date: 2010-03-09 00:00:00 -03:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: nokogiri
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
23
29
  version: "0"
24
- version:
30
+ type: :runtime
31
+ version_requirements: *id001
25
32
  description: |
26
33
  A simple OFX (Open Financial Exchange) parser built on top of Nokogiri. Currently supports OFX 1.0.2.
34
+
35
+ Usage:
36
+
37
+ OFX("sample.ofx") do |ofx|
38
+ p ofx
39
+ end
27
40
 
28
41
  email: fnando.vieira@gmail.com
29
42
  executables: []
@@ -35,16 +48,17 @@ extra_rdoc_files:
35
48
  files:
36
49
  - README.markdown
37
50
  - Rakefile
38
- - VERSION
39
51
  - lib/ofx.rb
40
52
  - lib/ofx/account.rb
41
53
  - lib/ofx/balance.rb
54
+ - lib/ofx/errors.rb
42
55
  - lib/ofx/foundation.rb
43
56
  - lib/ofx/parser.rb
44
57
  - lib/ofx/parser/ofx102.rb
45
58
  - lib/ofx/transaction.rb
46
59
  - lib/ofx/version.rb
47
60
  - ofx.gemspec
61
+ - spec/fixtures/invalid_version.ofx
48
62
  - spec/fixtures/sample.ofx
49
63
  - spec/ofx/account_spec.rb
50
64
  - spec/ofx/ofx102_spec.rb
@@ -52,7 +66,7 @@ files:
52
66
  - spec/ofx/ofx_spec.rb
53
67
  - spec/ofx/transaction_spec.rb
54
68
  - spec/spec_helper.rb
55
- has_rdoc: true
69
+ has_rdoc: false
56
70
  homepage: http://github.com/fnando/ofx
57
71
  licenses: []
58
72
 
@@ -65,18 +79,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - ">="
67
81
  - !ruby/object:Gem::Version
82
+ segments:
83
+ - 0
68
84
  version: "0"
69
- version:
70
85
  required_rubygems_version: !ruby/object:Gem::Requirement
71
86
  requirements:
72
87
  - - ">="
73
88
  - !ruby/object:Gem::Version
89
+ segments:
90
+ - 0
74
91
  version: "0"
75
- version:
76
92
  requirements: []
77
93
 
78
94
  rubyforge_project:
79
- rubygems_version: 1.3.5
95
+ rubygems_version: 1.3.6
80
96
  signing_key:
81
97
  specification_version: 3
82
98
  summary: A simple OFX (Open Financial Exchange) parser built on top of Nokogiri. Currently supports OFX 1.0.2.
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.2.0