ofx-parser 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Manifest.txt +2 -1
- data/Rakefile +0 -1
- data/lib/ofx-parser.rb +15 -1
- data/lib/ofx.rb +7 -2
- data/test/fixtures/list.ofx.sgml +53 -0
- data/test/test_ofx_parser.rb +11 -0
- metadata +3 -2
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
data/Rakefile
CHANGED
@@ -11,7 +11,6 @@ Hoe.new('ofx-parser', OfxParser::VERSION) do |p|
|
|
11
11
|
p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
|
12
12
|
p.url = 'http://ofx-parser.rubyforge.org/'
|
13
13
|
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
|
14
|
-
p.remote_rdoc_dir = '' # Release to root
|
15
14
|
p.extra_deps << ["hpricot", ">= 0.6"]
|
16
15
|
p.need_zip = true
|
17
16
|
p.need_tar = false
|
data/lib/ofx-parser.rb
CHANGED
@@ -7,7 +7,7 @@ require 'date'
|
|
7
7
|
end
|
8
8
|
|
9
9
|
module OfxParser
|
10
|
-
VERSION = '1.0.
|
10
|
+
VERSION = '1.0.1'
|
11
11
|
|
12
12
|
class OfxParser
|
13
13
|
|
@@ -79,6 +79,7 @@ module OfxParser
|
|
79
79
|
ofx = Ofx.new
|
80
80
|
|
81
81
|
ofx.sign_on = build_signon((doc/"SIGNONMSGSRSV1/SONRS"))
|
82
|
+
ofx.signup_account_info = build_info((doc/"SIGNUPMSGSRSV1/ACCTINFOTRNRS"))
|
82
83
|
ofx.bank_account = build_bank((doc/"BANKMSGSRSV1/STMTTRNRS")) unless (doc/"BANKMSGSRSV1").empty?
|
83
84
|
ofx.credit_card = build_credit((doc/"CREDITCARDMSGSRSV1/CCSTMTTRNRS")) unless (doc/"CREDITCARDMSGSRSV1").empty?
|
84
85
|
#build_investment((doc/"SIGNONMSGSRQV1"))
|
@@ -98,6 +99,19 @@ module OfxParser
|
|
98
99
|
sign_on
|
99
100
|
end
|
100
101
|
|
102
|
+
def self.build_info(doc)
|
103
|
+
account_infos = []
|
104
|
+
|
105
|
+
(doc/"ACCTINFO").each do |info_doc|
|
106
|
+
acc_info = AccountInfo.new
|
107
|
+
acc_info.desc = (info_doc/"DESC").inner_text
|
108
|
+
acc_info.number = (info_doc/"ACCTID").inner_text
|
109
|
+
account_infos << acc_info
|
110
|
+
end
|
111
|
+
|
112
|
+
account_infos
|
113
|
+
end
|
114
|
+
|
101
115
|
def self.build_bank(doc)
|
102
116
|
acct = BankAccount.new
|
103
117
|
|
data/lib/ofx.rb
CHANGED
@@ -10,7 +10,7 @@ module OfxParser
|
|
10
10
|
end
|
11
11
|
|
12
12
|
# Returns pennies for a given string amount, i.e:
|
13
|
-
# '-123.45' => 12345
|
13
|
+
# '-123.45' => -12345
|
14
14
|
# '123' => 12300
|
15
15
|
def pennies_for(amount)
|
16
16
|
return nil if amount == ""
|
@@ -47,7 +47,8 @@ module OfxParser
|
|
47
47
|
# * currency symbols are an iso4217 3-letter code
|
48
48
|
# * language is defined by iso639 3-letter code
|
49
49
|
class Ofx
|
50
|
-
attr_accessor :header, :sign_on, :
|
50
|
+
attr_accessor :header, :sign_on, :signup_account_info,
|
51
|
+
:bank_account, :credit_card, :investment
|
51
52
|
|
52
53
|
def accounts
|
53
54
|
accounts = []
|
@@ -63,6 +64,10 @@ module OfxParser
|
|
63
64
|
attr_accessor :status, :date, :language, :institute
|
64
65
|
end
|
65
66
|
|
67
|
+
class AccountInfo
|
68
|
+
attr_accessor :desc, :number
|
69
|
+
end
|
70
|
+
|
66
71
|
class Account
|
67
72
|
attr_accessor :number, :statement, :transaction_uid
|
68
73
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
OFXHEADER:100
|
2
|
+
DATA:OFXSGML
|
3
|
+
VERSION:102
|
4
|
+
SECURITY:NONE
|
5
|
+
ENCODING:USASCII
|
6
|
+
CHARSET:1252
|
7
|
+
COMPRESSION:NONE
|
8
|
+
OLDFILEUID:NONE
|
9
|
+
NEWFILEUID:e1dffb32-0a88-1111-12fb-111056c11111
|
10
|
+
|
11
|
+
<OFX>
|
12
|
+
<SIGNONMSGSRSV1>
|
13
|
+
<SONRS>
|
14
|
+
<STATUS>
|
15
|
+
<CODE>0
|
16
|
+
<SEVERITY>INFO
|
17
|
+
</STATUS>
|
18
|
+
<DTSERVER>20070702051227
|
19
|
+
<LANGUAGE>ENG
|
20
|
+
<DTPROFUP>20040828230101
|
21
|
+
<FI>
|
22
|
+
<ORG>Citigroup
|
23
|
+
<FID>24909
|
24
|
+
</FI>
|
25
|
+
<SESSCOOKIE>11111
|
26
|
+
</SONRS>
|
27
|
+
</SIGNONMSGSRSV1>
|
28
|
+
<SIGNUPMSGSRSV1>
|
29
|
+
<ACCTINFOTRNRS>
|
30
|
+
<TRNUID>e1dffb32-0a88-1111-12fb-111056c11111
|
31
|
+
<STATUS>
|
32
|
+
<CODE>0
|
33
|
+
<SEVERITY>INFO
|
34
|
+
</STATUS>
|
35
|
+
<CLTCOOKIE>4
|
36
|
+
<ACCTINFORS>
|
37
|
+
<DTACCTUP>20070702045709
|
38
|
+
<ACCTINFO>
|
39
|
+
<DESC>CREDIT CARD ************1111
|
40
|
+
<CCACCTINFO>
|
41
|
+
<CCACCTFROM>
|
42
|
+
<ACCTID>XXXXXXXXXXXX1111
|
43
|
+
</CCACCTFROM>
|
44
|
+
<SUPTXDL>Y
|
45
|
+
<XFERSRC>N
|
46
|
+
<XFERDEST>N
|
47
|
+
<SVCSTATUS>ACTIVE
|
48
|
+
</CCACCTINFO>
|
49
|
+
</ACCTINFO>
|
50
|
+
</ACCTINFORS>
|
51
|
+
</ACCTINFOTRNRS>
|
52
|
+
</SIGNUPMSGSRSV1>
|
53
|
+
</OFX>
|
data/test/test_ofx_parser.rb
CHANGED
@@ -193,6 +193,17 @@ class OfxParserTest < Test::Unit::TestCase
|
|
193
193
|
assert_equal '', transactions[2].memo
|
194
194
|
|
195
195
|
assert_equal 1, ofx.accounts.size
|
196
|
+
assert_equal [], ofx.signup_account_info
|
197
|
+
end
|
198
|
+
|
199
|
+
def test_account_listing
|
200
|
+
ofx = OfxParser::OfxParser.parse(OFX_FILES[:list])
|
201
|
+
|
202
|
+
cc_info = ofx.signup_account_info.first
|
203
|
+
assert_equal 'CREDIT CARD ************1111', cc_info.desc
|
204
|
+
assert_equal 'XXXXXXXXXXXX1111', cc_info.number
|
205
|
+
|
206
|
+
assert_equal 0, ofx.accounts.size
|
196
207
|
end
|
197
208
|
|
198
209
|
def test_monetary_support_call
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
|
|
3
3
|
specification_version: 1
|
4
4
|
name: ofx-parser
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.0.
|
7
|
-
date: 2007-
|
6
|
+
version: 1.0.1
|
7
|
+
date: 2007-07-02 00:00:00 -07:00
|
8
8
|
summary: ofx-parser is a ruby library for parsing OFX 1.x data.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -39,6 +39,7 @@ files:
|
|
39
39
|
- lib/sic.rb
|
40
40
|
- test/fixtures/banking.ofx.sgml
|
41
41
|
- test/fixtures/creditcard.ofx.sgml
|
42
|
+
- test/fixtures/list.ofx.sgml
|
42
43
|
- test/fixtures/with_spaces.ofx.sgml
|
43
44
|
- test/test_ofx_parser.rb
|
44
45
|
test_files:
|