ofx 0.2.3 → 0.2.4
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/lib/ofx/errors.rb +1 -1
- data/lib/ofx/parser.rb +7 -2
- data/lib/ofx/version.rb +1 -1
- data/ofx.gemspec +3 -2
- data/spec/fixtures/avatar.gif +0 -0
- data/spec/ofx/ofx_parser_spec.rb +7 -1
- metadata +4 -3
data/lib/ofx/errors.rb
CHANGED
data/lib/ofx/parser.rb
CHANGED
@@ -7,14 +7,17 @@ module OFX
|
|
7
7
|
attr_reader :parser
|
8
8
|
|
9
9
|
def initialize(resource)
|
10
|
-
|
10
|
+
resource = open_resource(resource)
|
11
|
+
resource.rewind
|
12
|
+
|
13
|
+
@content = resource.read
|
11
14
|
@headers, @body = prepare(content)
|
12
15
|
|
13
16
|
case @headers["VERSION"]
|
14
17
|
when "102" then
|
15
18
|
@parser = OFX::Parser::OFX102.new(:headers => headers, :body => body)
|
16
19
|
else
|
17
|
-
raise OFX::
|
20
|
+
raise OFX::UnsupportedFileError
|
18
21
|
end
|
19
22
|
end
|
20
23
|
|
@@ -35,6 +38,8 @@ module OFX
|
|
35
38
|
# Split headers & body
|
36
39
|
headers, body = content.dup.split(/\n{2,}|:?<OFX>/, 2)
|
37
40
|
|
41
|
+
raise OFX::UnsupportedFileError unless body
|
42
|
+
|
38
43
|
# Parse headers. When value is NONE, convert it to nil.
|
39
44
|
headers = headers.to_enum(:each_line).inject({}) do |memo, line|
|
40
45
|
_, key, value = *line.match(/^(.*?):(.*?)(\r?\n)*$/)
|
data/lib/ofx/version.rb
CHANGED
data/ofx.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ofx}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.4"
|
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{2010-03-
|
12
|
+
s.date = %q{2010-03-10}
|
13
13
|
s.description = %q{A simple OFX (Open Financial Exchange) parser built on top of Nokogiri. Currently supports OFX 1.0.2.
|
14
14
|
|
15
15
|
Usage:
|
@@ -34,6 +34,7 @@ Usage:
|
|
34
34
|
"lib/ofx/transaction.rb",
|
35
35
|
"lib/ofx/version.rb",
|
36
36
|
"ofx.gemspec",
|
37
|
+
"spec/fixtures/avatar.gif",
|
37
38
|
"spec/fixtures/invalid_version.ofx",
|
38
39
|
"spec/fixtures/sample.ofx",
|
39
40
|
"spec/ofx/account_spec.rb",
|
Binary file
|
data/spec/ofx/ofx_parser_spec.rb
CHANGED
@@ -33,7 +33,13 @@ describe OFX::Parser do
|
|
33
33
|
it "should raise exception when trying to parse an unsupported OFX version" do
|
34
34
|
lambda {
|
35
35
|
OFX::Parser::Base.new("spec/fixtures/invalid_version.ofx")
|
36
|
-
}.should raise_error(OFX::
|
36
|
+
}.should raise_error(OFX::UnsupportedFileError)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should raise exception when trying to parse an invalid file" do
|
40
|
+
lambda {
|
41
|
+
OFX::Parser::Base.new("spec/fixtures/avatar.gif")
|
42
|
+
}.should raise_error(OFX::UnsupportedFileError)
|
37
43
|
end
|
38
44
|
|
39
45
|
describe "headers" do
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 4
|
9
|
+
version: 0.2.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Nando Vieira
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-03-
|
17
|
+
date: 2010-03-10 00:00:00 -03:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- lib/ofx/transaction.rb
|
58
58
|
- lib/ofx/version.rb
|
59
59
|
- ofx.gemspec
|
60
|
+
- spec/fixtures/avatar.gif
|
60
61
|
- spec/fixtures/invalid_version.ofx
|
61
62
|
- spec/fixtures/sample.ofx
|
62
63
|
- spec/ofx/account_spec.rb
|