ofxparser 1.0.0
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 +14 -0
- data/README.txt +107 -0
- data/Rakefile +23 -0
- data/lib/class-extension.rb +154 -0
- data/lib/mcc.rb +674 -0
- data/lib/ofx.rb +189 -0
- data/lib/ofxparser.rb +236 -0
- data/test/test_ofxparser.rb +8 -0
- metadata +91 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
README.txt
|
4
|
+
Rakefile
|
5
|
+
lib/class-extension.rb
|
6
|
+
lib/mcc.rb
|
7
|
+
lib/ofxparser.rb
|
8
|
+
lib/ofx.rb
|
9
|
+
test/fixtures/banking.ofx.sgml
|
10
|
+
test/fixtures/creditcard.ofx.sgml
|
11
|
+
test/fixtures/list.ofx.sgml
|
12
|
+
test/fixtures/malformed_header.ofx.sgml
|
13
|
+
test/fixtures/with_spaces.ofx.sgml
|
14
|
+
test/test_ofxparser.rb
|
data/README.txt
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
== ofx-parser
|
2
|
+
by Andrew A. Smith
|
3
|
+
|
4
|
+
Forked by Pavit Masson
|
5
|
+
|
6
|
+
http://ofx-parser.rubyforge.org/
|
7
|
+
http://rubyforge.org/projects/ofx-parser/
|
8
|
+
|
9
|
+
== DESCRIPTION:
|
10
|
+
|
11
|
+
ofx-parser is a ruby library to parse a realistic subset of the lengthy OFX 1.x specification.
|
12
|
+
|
13
|
+
I forked aasmith's project in an attempt to build the investment account methods.
|
14
|
+
|
15
|
+
== FEATURES/PROBLEMS:
|
16
|
+
|
17
|
+
* Reads OFX responses - i.e. those downloaded from financial institutions and
|
18
|
+
puts it into a usable object graph.
|
19
|
+
* Supports the 3 main message sets: banking, credit card and investment
|
20
|
+
accounts, as well as the required 'sign on' set.
|
21
|
+
* Knows about SIC codes - if your institution provides them.
|
22
|
+
See http://www.eeoc.gov/stats/jobpat/siccodes.html
|
23
|
+
* Monetary amounts can be retrieved either as a raw string, or in pennies.
|
24
|
+
* Supports OFX timestamps.
|
25
|
+
|
26
|
+
== SYNOPSIS:
|
27
|
+
|
28
|
+
Supports bank accounts:
|
29
|
+
|
30
|
+
require 'rubygems'
|
31
|
+
require 'ofxparser'
|
32
|
+
|
33
|
+
ofx = OfxParser::OfxParser.parse(open("bank-statement.ofx"))
|
34
|
+
|
35
|
+
ofx.bank_account.number # => '103333333333'
|
36
|
+
ofx.bank_account.routing_number # => '033000033'
|
37
|
+
ofx.bank_account.balance # => '123.45'
|
38
|
+
ofx.bank_account.balance_in_pennies # => 12345
|
39
|
+
|
40
|
+
ofx.bank_account.statement.start_date # => DateTime
|
41
|
+
ofx.bank_account.statement.end_date # => DateTime
|
42
|
+
|
43
|
+
ofx.bank_account.statement.transactions.size # => 4
|
44
|
+
|
45
|
+
ofx.bank_account.statement.transactions.first.payee # => "FOO, INC."
|
46
|
+
ofx.bank_account.statement.transactions.first.type # => :DEBIT
|
47
|
+
ofx.bank_account.statement.transactions.first.amount # => '-11.11'
|
48
|
+
ofx.bank_account.statement.transactions.first.amount_in_pennies # => -1111
|
49
|
+
|
50
|
+
Also supports credit cards...
|
51
|
+
|
52
|
+
ofx = OfxParser::OfxParser.parse(open("creditcard-statement.ofx"))
|
53
|
+
|
54
|
+
ofx.credit_card.remaining_credit # => '19000.0'
|
55
|
+
ofx.credit_card.remaining_credit_in_pennies # => '1900000'
|
56
|
+
|
57
|
+
ofx.credit_card.statement.start_date # => DateTime
|
58
|
+
ofx.credit_card.statement.end_date # => DateTime
|
59
|
+
|
60
|
+
ofx.credit_card.statement.transactions.size # => 10
|
61
|
+
|
62
|
+
ofx.credit_card.statement.transactions.first.type # => :DEBIT
|
63
|
+
ofx.credit_card.statement.transactions.first.amount # => '-19.17'
|
64
|
+
ofx.credit_card.statement.transactions.first.amount_in_pennies # => '-1917'
|
65
|
+
ofx.credit_card.statement.transactions.first.sic # => '7933'
|
66
|
+
ofx.credit_card.statement.transactions.first.sic_desc # => 'BOWLING CENTERS'
|
67
|
+
ofx.credit_card.statement.transactions.first.payee # => 'SUNSET BOWLING'
|
68
|
+
|
69
|
+
Working on investment accounts...
|
70
|
+
|
71
|
+
== REQUIREMENTS:
|
72
|
+
|
73
|
+
* hpricot >= 0.6
|
74
|
+
|
75
|
+
== INSTALL:
|
76
|
+
|
77
|
+
* gem install ofxparser
|
78
|
+
|
79
|
+
== LICENSE:
|
80
|
+
|
81
|
+
Copyright (c) 2007, Andrew A. Smith
|
82
|
+
All rights reserved.
|
83
|
+
|
84
|
+
Redistribution and use in source and binary forms, with or without modification,
|
85
|
+
are permitted provided that the following conditions are met:
|
86
|
+
|
87
|
+
* Redistributions of source code must retain the above copyright notice,
|
88
|
+
this list of conditions and the following disclaimer.
|
89
|
+
|
90
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
91
|
+
this list of conditions and the following disclaimer in the documentation
|
92
|
+
and/or other materials provided with the distribution.
|
93
|
+
|
94
|
+
* Neither the name of the copyright owner nor the names of its contributors
|
95
|
+
may be used to endorse or promote products derived from this software
|
96
|
+
without specific prior written permission.
|
97
|
+
|
98
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
99
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
100
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
101
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
102
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
103
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
104
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
105
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
106
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
107
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
|
6
|
+
# Hoe.plugin :compiler
|
7
|
+
# Hoe.plugin :gem_prelude_sucks
|
8
|
+
# Hoe.plugin :inline
|
9
|
+
# Hoe.plugin :racc
|
10
|
+
# Hoe.plugin :rubyforge
|
11
|
+
|
12
|
+
Hoe.new('ofxparser', OfxParser::VERSION) do |p|
|
13
|
+
p.author = 'Pavit Masson (forked from Andrew A. Smith)'
|
14
|
+
p.email = 'pavitm@gmail.com'
|
15
|
+
p.rubyforge_name = 'ofxparser'
|
16
|
+
p.summary = 'ofxparser is a modified version of aasmith''s gem, where I attempt to build the investment account part.'
|
17
|
+
p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
|
18
|
+
p.url = 'http://ofxparser.rubyforge.org/'
|
19
|
+
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
|
20
|
+
p.extra_deps << ["hpricot", ">= 0.6"]
|
21
|
+
p.need_zip = true
|
22
|
+
p.need_tar = false
|
23
|
+
end
|
@@ -0,0 +1,154 @@
|
|
1
|
+
# = class_extension.rb
|
2
|
+
#
|
3
|
+
# == Copyright (c) 2006 Daniel Schierbeck
|
4
|
+
#
|
5
|
+
# Ruby License
|
6
|
+
#
|
7
|
+
# This module is free software. You may use, modify, and/or redistribute this
|
8
|
+
# software under the same terms as Ruby.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful, but WITHOUT
|
11
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
12
|
+
# FOR A PARTICULAR PURPOSE.
|
13
|
+
#
|
14
|
+
# == Special Thanks
|
15
|
+
#
|
16
|
+
# Thanks to Trans, Nobu and Ulysses for their original on this concept.
|
17
|
+
#
|
18
|
+
# == Authors and Contributors
|
19
|
+
#
|
20
|
+
# * Daniel Schierbeck
|
21
|
+
# * Thomas Sawyer
|
22
|
+
# * Nobu Nakada
|
23
|
+
# * Ulysses
|
24
|
+
|
25
|
+
# Author:: Daniel Schierbeck
|
26
|
+
# Copyright:: Copyright (c) 2006 Daniel Schierbeck
|
27
|
+
# License:: Ruby License
|
28
|
+
|
29
|
+
#
|
30
|
+
|
31
|
+
class Module #:nodoc: all
|
32
|
+
|
33
|
+
alias_method :append_features_without_class_extension, :append_features
|
34
|
+
|
35
|
+
# = class_extension
|
36
|
+
#
|
37
|
+
# Normally when including modules, class/module methods are not
|
38
|
+
# extended. To achieve this behavior requires some clever
|
39
|
+
# Ruby Karate. Instead class_extension provides an easy to use
|
40
|
+
# and clean solution. Simply place the extending class methods
|
41
|
+
# in a block of the special module method #class_extension.
|
42
|
+
#
|
43
|
+
# module Mix
|
44
|
+
# def inst_meth
|
45
|
+
# puts 'inst_meth'
|
46
|
+
# end
|
47
|
+
#
|
48
|
+
# class_extension do
|
49
|
+
# def class_meth
|
50
|
+
# "Class Method!"
|
51
|
+
# end
|
52
|
+
# end
|
53
|
+
# end
|
54
|
+
#
|
55
|
+
# class X
|
56
|
+
# include Mix
|
57
|
+
# end
|
58
|
+
#
|
59
|
+
# X.class_meth #=> "Class Method!"
|
60
|
+
#
|
61
|
+
|
62
|
+
def class_extension(&block)
|
63
|
+
@class_extension ||= Module.new do
|
64
|
+
def self.append_features(mod)
|
65
|
+
append_features_without_class_extension(mod)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
@class_extension.module_eval(&block) if block_given?
|
69
|
+
@class_extension
|
70
|
+
end
|
71
|
+
|
72
|
+
private :class_extension
|
73
|
+
|
74
|
+
def append_features(mod)
|
75
|
+
append_features_without_class_extension(mod)
|
76
|
+
mod.extend(class_extension)
|
77
|
+
if mod.instance_of? Module
|
78
|
+
mod.__send__(:class_extension).__send__(:include, class_extension)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
class Class #:nodoc: all
|
85
|
+
undef_method :class_extension
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
# _____ _
|
91
|
+
# |_ _|__ ___| |_
|
92
|
+
# | |/ _ \/ __| __|
|
93
|
+
# | | __/\__ \ |_
|
94
|
+
# |_|\___||___/\__|
|
95
|
+
#
|
96
|
+
|
97
|
+
=begin test
|
98
|
+
|
99
|
+
require 'test/unit'
|
100
|
+
|
101
|
+
class TC_ClassMethods < Test::Unit::TestCase
|
102
|
+
|
103
|
+
# fixture
|
104
|
+
|
105
|
+
module N
|
106
|
+
class_extension do
|
107
|
+
def n ; 43 ; end
|
108
|
+
def s ; self ; end
|
109
|
+
end
|
110
|
+
extend class_extension
|
111
|
+
end
|
112
|
+
|
113
|
+
class X
|
114
|
+
include N
|
115
|
+
def n ; 11 ; end
|
116
|
+
end
|
117
|
+
|
118
|
+
module K
|
119
|
+
include N
|
120
|
+
class_extension do
|
121
|
+
def n ; super + 1 ; end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
class Z
|
126
|
+
include K
|
127
|
+
end
|
128
|
+
|
129
|
+
# tests
|
130
|
+
|
131
|
+
def test_01
|
132
|
+
assert_equal( 43, N.n )
|
133
|
+
assert_equal( N, N.s )
|
134
|
+
end
|
135
|
+
def test_02
|
136
|
+
assert_equal( 43, X.n )
|
137
|
+
assert_equal( X, X.s )
|
138
|
+
end
|
139
|
+
def test_03
|
140
|
+
assert_equal( 11, X.new.n )
|
141
|
+
end
|
142
|
+
def test_04
|
143
|
+
assert_equal( 43, K.n ) #notic the difference!
|
144
|
+
assert_equal( K, K.s )
|
145
|
+
end
|
146
|
+
def test_05
|
147
|
+
assert_equal( 44, Z.n )
|
148
|
+
assert_equal( Z, Z.s )
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
152
|
+
|
153
|
+
=end
|
154
|
+
|