Skip to content

Commit 996adbc

Browse files
committed
Refact parser logic to use OFX 1.0.2 for version 103 files
1 parent db167ff commit 996adbc

File tree

8 files changed

+44
-160
lines changed

8 files changed

+44
-160
lines changed

Gemfile.lock

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
PATH
22
remote: .
33
specs:
4-
ofx (0.3.6)
4+
ofx (0.3.7)
55
nokogiri (>= 1.13.1, < 1.16.0)
66

77
GEM
88
remote: https://rubygems.org/
99
specs:
1010
byebug (11.1.3)
1111
diff-lcs (1.5.1)
12-
nokogiri (1.15.7-x86_64-darwin)
12+
mini_portile2 (2.8.9)
13+
nokogiri (1.15.7)
14+
mini_portile2 (~> 2.8.2)
1315
racc (~> 1.4)
1416
racc (1.8.1)
1517
rake (13.0.6)

lib/ofx.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
require 'ofx/errors'
1010
require 'ofx/parser'
1111
require 'ofx/parser/ofx102'
12-
require 'ofx/parser/ofx103'
1312
require 'ofx/parser/ofx211'
1413
require 'ofx/foundation'
1514
require 'ofx/balance'

lib/ofx/parser.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ def initialize(resource)
1717
end
1818

1919
case headers["VERSION"]
20-
when /100|102/ then
20+
when /100|102|103/ then
2121
@parser = OFX102.new(:headers => headers, :body => body)
22-
when /103/ then
23-
@parser = OFX103.new(:headers => headers, :body => body)
2422
when /200|202|211|220/ then
2523
@parser = OFX211.new(:headers => headers, :body => body)
2624
else

lib/ofx/parser/ofx103.rb

Lines changed: 0 additions & 7 deletions
This file was deleted.

lib/ofx/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module OFX
22
module Version
33
MAJOR = 0
44
MINOR = 3
5-
PATCH = 6
5+
PATCH = 7
66
STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
77
end
88
end

spec/fixtures/v103.ofx

Lines changed: 0 additions & 80 deletions
This file was deleted.

spec/ofx/ofx103_spec.rb

Lines changed: 0 additions & 50 deletions
This file was deleted.

spec/ofx/ofx_parser_spec.rb

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
require "spec_helper"
22

33
describe OFX::Parser do
4+
def ofx_example_to(version)
5+
<<~OFX_CONTENT
6+
<?xml version="1.0" encoding="US-ASCII"?>
7+
8+
<?OFX OFXHEADER="200" VERSION="#{version}" SECURITY="NONE" OLDFILEUID="NONE" NEWFILEUID="NONE"?>"
9+
10+
<OFX>
11+
</OFX>
12+
OFX_CONTENT
13+
end
14+
415
before do
516
@ofx = OFX::Parser::Base.new("spec/fixtures/sample.ofx")
617
end
@@ -47,30 +58,50 @@
4758
}.should raise_error(OFX::UnsupportedFileError)
4859
end
4960

50-
it "uses 102 parser to parse version 100 ofx files" do
61+
it "should use 102 parser to parse version 100 ofx files" do
62+
expect(OFX::Parser::OFX102).to receive(:new).and_return('ofx-102-parser')
63+
64+
ofx = OFX::Parser::Base.new(ofx_example_to('100'))
65+
expect(ofx.parser).to eql 'ofx-102-parser'
66+
end
67+
68+
it "should use 102 parser to parse version 102 ofx files" do
69+
expect(OFX::Parser::OFX102).to receive(:new).and_return('ofx-102-parser')
70+
71+
ofx = OFX::Parser::Base.new(ofx_example_to('102'))
72+
expect(ofx.parser).to eql 'ofx-102-parser'
73+
end
74+
75+
it "should use 102 parser to parse version 103 ofx files" do
5176
expect(OFX::Parser::OFX102).to receive(:new).and_return('ofx-102-parser')
5277

53-
ofx = OFX::Parser::Base.new(ofx_2_example('100'))
78+
ofx = OFX::Parser::Base.new(ofx_example_to('103'))
5479
expect(ofx.parser).to eql 'ofx-102-parser'
5580
end
5681

57-
it "uses 211 parser to parse version 200 ofx files" do
82+
it "should use 211 parser to parse version 200 ofx files" do
5883
expect(OFX::Parser::OFX211).to receive(:new).and_return('ofx-211-parser')
5984

60-
ofx = OFX::Parser::Base.new(ofx_2_example('200'))
85+
ofx = OFX::Parser::Base.new(ofx_example_to('200'))
6186
ofx.parser.should == 'ofx-211-parser'
6287
end
6388

6489
it "should use 211 parser to parse version 202 ofx files" do
6590
OFX::Parser::OFX211.stub(:new).and_return('ofx-211-parser')
66-
ofx = OFX::Parser::Base.new(ofx_2_example('202'))
91+
ofx = OFX::Parser::Base.new(ofx_example_to('202'))
92+
ofx.parser.should == 'ofx-211-parser'
93+
end
94+
95+
it "should use 211 parser to parse version 211 ofx files" do
96+
OFX::Parser::OFX211.stub(:new).and_return('ofx-211-parser')
97+
ofx = OFX::Parser::Base.new(ofx_example_to('211'))
6798
ofx.parser.should == 'ofx-211-parser'
6899
end
69100

70-
it "uses 211 parser to parse version 220 ofx files" do
101+
it "should use 211 parser to parse version 220 ofx files" do
71102
expect(OFX::Parser::OFX211).to receive(:new).and_return('ofx-211-parser')
72103

73-
ofx = OFX::Parser::Base.new(ofx_2_example('220'))
104+
ofx = OFX::Parser::Base.new(ofx_example_to('220'))
74105
expect(ofx.parser).to eql 'ofx-211-parser'
75106
end
76107

@@ -124,13 +155,4 @@
124155
@ofx.headers.size.should be(9)
125156
end
126157
end
127-
128-
def ofx_2_example(version)
129-
<<-EndOfx
130-
<?xml version="1.0" encoding="US-ASCII"?>
131-
<?OFX OFXHEADER="200" VERSION="#{version}" SECURITY="NONE" OLDFILEUID="NONE" NEWFILEUID="NONE"?>"
132-
<OFX>
133-
</OFX>
134-
EndOfx
135-
end
136158
end

0 commit comments

Comments
 (0)