ofx_ruby 0.0.13 → 0.0.14
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.
- checksums.yaml +4 -4
- data/lib/ofx/handler.rb +30 -14
- data/lib/ofx/parser.rb +8 -0
- data/lib/ofx/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b41ef0ed969fef00bb94b4685bc08edf1c1f301b
|
4
|
+
data.tar.gz: bfbe06e5523d12018f521bd39e9053a18dd35074
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2eef49cd742e94af56db6e2e4e1437609fed4d8933cad65e0e6f7ab0732a584a03e8de1dff1669589c8da293c5b0c6e32cdf593d92a529a42f580d4a8c97d3f
|
7
|
+
data.tar.gz: f17dc8ad3b4f30cb9ae0f29e2f324abffe0647b4b73bc3c3e18b2c652e66b3124f38859a1fd6db20167fe99caf2e0b597a7cc5ba51203d3d3c59e3a52a2efae2
|
data/lib/ofx/handler.rb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
module OFX
|
3
3
|
class Handler < Ox::Sax
|
4
4
|
TRANSACTION_ATTRS = [:TRNTYPE, :DTPOSTED, :TRNAMT, :FITID, :NAME]
|
5
|
-
|
5
|
+
BALANCE_ATTRS = [:BALAMT]
|
6
|
+
ATTRS_MAP = { TRNTYPE: :as_s, DTPOSTED: :as_time, BALAMT: :as_f,
|
6
7
|
TRNAMT: :as_f, FITID: :as_s, NAME: :as_s }
|
7
8
|
|
8
9
|
def initialize(parser)
|
@@ -10,25 +11,40 @@ module OFX
|
|
10
11
|
end
|
11
12
|
|
12
13
|
def start_element(name)
|
13
|
-
|
14
|
-
@
|
14
|
+
case name
|
15
|
+
when :STMTTRN then @transaction = {}
|
16
|
+
when :LEDGERBAL || :AVAILBAL then @balance = {}
|
17
|
+
end
|
18
|
+
@current = name
|
15
19
|
end
|
16
20
|
|
17
21
|
def value(value)
|
18
|
-
|
19
|
-
|
22
|
+
case
|
23
|
+
when TRANSACTION_ATTRS.include?(@current)
|
24
|
+
@transaction[@current] = value.send(ATTRS_MAP[@current])
|
25
|
+
when BALANCE_ATTRS.include?(@current)
|
26
|
+
@balance[@current] = value.send(ATTRS_MAP[@current])
|
27
|
+
end
|
20
28
|
end
|
21
29
|
|
22
30
|
def end_element(name)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
31
|
+
case name
|
32
|
+
when :STMTTRN
|
33
|
+
@parser.output[:transactions] = [] unless @parser.output[:transactions]
|
34
|
+
@parser.output[:transactions].push(transaction(@transaction))
|
35
|
+
when :LEDGERBAL
|
36
|
+
@parser.output[:balance] = @balance[:BALAMT]
|
37
|
+
when :AVAILBAL
|
38
|
+
@parser.output[:pending] = @balance[:BALAMT] - @parser.output[:balance]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
protected
|
43
|
+
|
44
|
+
def transaction(hash)
|
45
|
+
{ type: @transaction[:TRNTYPE], posted: @transaction[:DTPOSTED],
|
46
|
+
amount: @transaction[:TRNAMT], fitid: @transaction[:FITID],
|
47
|
+
name: @transaction[:NAME] }
|
32
48
|
end
|
33
49
|
end
|
34
50
|
end
|
data/lib/ofx/parser.rb
CHANGED
data/lib/ofx/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ofx_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rob
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|