ofx 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.
- data/VERSION +1 -1
- data/lib/ofx.rb +2 -2
- data/lib/ofx/parser.rb +15 -3
- data/ofx.gemspec +66 -0
- data/spec/ofx/ofx_parser_spec.rb +26 -13
- metadata +18 -8
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/ofx.rb
CHANGED
data/lib/ofx/parser.rb
CHANGED
@@ -6,8 +6,8 @@ module OFX
|
|
6
6
|
attr_reader :content
|
7
7
|
attr_reader :parser
|
8
8
|
|
9
|
-
def initialize(
|
10
|
-
@content =
|
9
|
+
def initialize(resource)
|
10
|
+
@content = open_resource(resource).read
|
11
11
|
@headers, @body = prepare(content)
|
12
12
|
|
13
13
|
@parser = case @headers["VERSION"]
|
@@ -17,10 +17,22 @@ module OFX
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
+
def open_resource(resource)
|
21
|
+
if resource.respond_to?(:read)
|
22
|
+
return resource
|
23
|
+
else
|
24
|
+
begin
|
25
|
+
return open(resource)
|
26
|
+
rescue
|
27
|
+
return StringIO.new(resource)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
20
32
|
private
|
21
33
|
def prepare(content)
|
22
34
|
# Split headers & body
|
23
|
-
headers, body = content.dup.split(/\n{2,}|:?<OFX>/, 2)
|
35
|
+
headers, body = content.dup.split(/\n{2,}|:?<OFX>/, 2)
|
24
36
|
|
25
37
|
# Parse headers. When value is NONE, convert it to nil.
|
26
38
|
headers = headers.to_enum(:each_line).inject({}) do |memo, line|
|
data/ofx.gemspec
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{ofx}
|
8
|
+
s.version = "0.2.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Nando Vieira"]
|
12
|
+
s.date = %q{2009-11-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
|
+
s.email = %q{fnando.vieira@gmail.com}
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"README.markdown"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
"README.markdown",
|
21
|
+
"Rakefile",
|
22
|
+
"VERSION",
|
23
|
+
"lib/ofx.rb",
|
24
|
+
"lib/ofx/account.rb",
|
25
|
+
"lib/ofx/balance.rb",
|
26
|
+
"lib/ofx/foundation.rb",
|
27
|
+
"lib/ofx/parser.rb",
|
28
|
+
"lib/ofx/parser/ofx102.rb",
|
29
|
+
"lib/ofx/transaction.rb",
|
30
|
+
"lib/ofx/version.rb",
|
31
|
+
"ofx.gemspec",
|
32
|
+
"spec/fixtures/sample.ofx",
|
33
|
+
"spec/ofx/account_spec.rb",
|
34
|
+
"spec/ofx/ofx102_spec.rb",
|
35
|
+
"spec/ofx/ofx_parser_spec.rb",
|
36
|
+
"spec/ofx/ofx_spec.rb",
|
37
|
+
"spec/ofx/transaction_spec.rb",
|
38
|
+
"spec/spec_helper.rb"
|
39
|
+
]
|
40
|
+
s.homepage = %q{http://github.com/fnando/ofx}
|
41
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
42
|
+
s.require_paths = ["lib"]
|
43
|
+
s.rubygems_version = %q{1.3.5}
|
44
|
+
s.summary = %q{A simple OFX (Open Financial Exchange) parser built on top of Nokogiri. Currently supports OFX 1.0.2.}
|
45
|
+
s.test_files = [
|
46
|
+
"spec/ofx/account_spec.rb",
|
47
|
+
"spec/ofx/ofx102_spec.rb",
|
48
|
+
"spec/ofx/ofx_parser_spec.rb",
|
49
|
+
"spec/ofx/ofx_spec.rb",
|
50
|
+
"spec/ofx/transaction_spec.rb",
|
51
|
+
"spec/spec_helper.rb"
|
52
|
+
]
|
53
|
+
|
54
|
+
if s.respond_to? :specification_version then
|
55
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
56
|
+
s.specification_version = 3
|
57
|
+
|
58
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
59
|
+
s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
|
60
|
+
else
|
61
|
+
s.add_dependency(%q<nokogiri>, [">= 0"])
|
62
|
+
end
|
63
|
+
else
|
64
|
+
s.add_dependency(%q<nokogiri>, [">= 0"])
|
65
|
+
end
|
66
|
+
end
|
data/spec/ofx/ofx_parser_spec.rb
CHANGED
@@ -4,55 +4,68 @@ describe OFX::Parser do
|
|
4
4
|
before do
|
5
5
|
@ofx = OFX::Parser::Base.new("spec/fixtures/sample.ofx")
|
6
6
|
end
|
7
|
-
|
8
|
-
it "should
|
7
|
+
|
8
|
+
it "should accept file path" do
|
9
|
+
@ofx = OFX::Parser::Base.new("spec/fixtures/sample.ofx")
|
10
|
+
@ofx.content.should_not be_nil
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should accept file handler" do
|
14
|
+
file = open("spec/fixtures/sample.ofx")
|
15
|
+
@ofx = OFX::Parser::Base.new(file)
|
9
16
|
@ofx.content.should_not be_nil
|
10
17
|
end
|
11
|
-
|
18
|
+
|
19
|
+
it "should accept file content" do
|
20
|
+
file = open("spec/fixtures/sample.ofx").read
|
21
|
+
@ofx = OFX::Parser::Base.new(file)
|
22
|
+
@ofx.content.should_not be_nil
|
23
|
+
end
|
24
|
+
|
12
25
|
it "should set content" do
|
13
26
|
@ofx.content.should == open("spec/fixtures/sample.ofx").read
|
14
27
|
end
|
15
|
-
|
28
|
+
|
16
29
|
it "should set body" do
|
17
30
|
@ofx.body.should_not be_nil
|
18
31
|
end
|
19
|
-
|
32
|
+
|
20
33
|
describe "headers" do
|
21
34
|
it "should have OFXHEADER" do
|
22
35
|
@ofx.headers["OFXHEADER"].should == "100"
|
23
36
|
end
|
24
|
-
|
37
|
+
|
25
38
|
it "should have DATA" do
|
26
39
|
@ofx.headers["DATA"].should == "OFXSGML"
|
27
40
|
end
|
28
|
-
|
41
|
+
|
29
42
|
it "should have VERSION" do
|
30
43
|
@ofx.headers["VERSION"].should == "102"
|
31
44
|
end
|
32
|
-
|
45
|
+
|
33
46
|
it "should have SECURITY" do
|
34
47
|
@ofx.headers.should have_key("SECURITY")
|
35
48
|
@ofx.headers["SECURITY"].should be_nil
|
36
49
|
end
|
37
|
-
|
50
|
+
|
38
51
|
it "should have ENCODING" do
|
39
52
|
@ofx.headers["ENCODING"].should == "USASCII"
|
40
53
|
end
|
41
|
-
|
54
|
+
|
42
55
|
it "should have CHARSET" do
|
43
56
|
@ofx.headers["CHARSET"].should == "1252"
|
44
57
|
end
|
45
|
-
|
58
|
+
|
46
59
|
it "should have COMPRESSION" do
|
47
60
|
@ofx.headers.should have_key("COMPRESSION")
|
48
61
|
@ofx.headers["COMPRESSION"].should be_nil
|
49
62
|
end
|
50
|
-
|
63
|
+
|
51
64
|
it "should have OLDFILEUID" do
|
52
65
|
@ofx.headers.should have_key("OLDFILEUID")
|
53
66
|
@ofx.headers["OLDFILEUID"].should be_nil
|
54
67
|
end
|
55
|
-
|
68
|
+
|
56
69
|
it "should have NEWFILEUID" do
|
57
70
|
@ofx.headers.should have_key("NEWFILEUID")
|
58
71
|
@ofx.headers["NEWFILEUID"].should be_nil
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ofx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nando Vieira
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-13 00:00:00 -02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -22,7 +22,9 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: "0"
|
24
24
|
version:
|
25
|
-
description:
|
25
|
+
description: |
|
26
|
+
A simple OFX (Open Financial Exchange) parser built on top of Nokogiri. Currently supports OFX 1.0.2.
|
27
|
+
|
26
28
|
email: fnando.vieira@gmail.com
|
27
29
|
executables: []
|
28
30
|
|
@@ -42,6 +44,7 @@ files:
|
|
42
44
|
- lib/ofx/parser/ofx102.rb
|
43
45
|
- lib/ofx/transaction.rb
|
44
46
|
- lib/ofx/version.rb
|
47
|
+
- ofx.gemspec
|
45
48
|
- spec/fixtures/sample.ofx
|
46
49
|
- spec/ofx/account_spec.rb
|
47
50
|
- spec/ofx/ofx102_spec.rb
|
@@ -49,8 +52,10 @@ files:
|
|
49
52
|
- spec/ofx/ofx_spec.rb
|
50
53
|
- spec/ofx/transaction_spec.rb
|
51
54
|
- spec/spec_helper.rb
|
52
|
-
has_rdoc:
|
55
|
+
has_rdoc: true
|
53
56
|
homepage: http://github.com/fnando/ofx
|
57
|
+
licenses: []
|
58
|
+
|
54
59
|
post_install_message:
|
55
60
|
rdoc_options:
|
56
61
|
- --charset=UTF-8
|
@@ -71,9 +76,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
76
|
requirements: []
|
72
77
|
|
73
78
|
rubyforge_project:
|
74
|
-
rubygems_version: 1.3.
|
79
|
+
rubygems_version: 1.3.5
|
75
80
|
signing_key:
|
76
|
-
specification_version:
|
81
|
+
specification_version: 3
|
77
82
|
summary: A simple OFX (Open Financial Exchange) parser built on top of Nokogiri. Currently supports OFX 1.0.2.
|
78
|
-
test_files:
|
79
|
-
|
83
|
+
test_files:
|
84
|
+
- spec/ofx/account_spec.rb
|
85
|
+
- spec/ofx/ofx102_spec.rb
|
86
|
+
- spec/ofx/ofx_parser_spec.rb
|
87
|
+
- spec/ofx/ofx_spec.rb
|
88
|
+
- spec/ofx/transaction_spec.rb
|
89
|
+
- spec/spec_helper.rb
|