syrup 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
@@ -144,6 +144,43 @@ module Syrup
|
|
144
144
|
currency.scan(/[0-9.]/).join.to_f
|
145
145
|
end
|
146
146
|
|
147
|
+
# A helper method that replaces a few HTML entities with their actual characters
|
148
|
+
#
|
149
|
+
# unescape_html("You & I") #=> "You & I"
|
150
|
+
def unescape_html(str)
|
151
|
+
str.gsub(/&(.*?);/n) do
|
152
|
+
match = $1.dup
|
153
|
+
case match
|
154
|
+
when /\Aamp\z/ni then '&'
|
155
|
+
when /\Aquot\z/ni then '"'
|
156
|
+
when /\Agt\z/ni then '>'
|
157
|
+
when /\Alt\z/ni then '<'
|
158
|
+
when /\A#0*(\d+)\z/n then
|
159
|
+
if Integer($1) < 256
|
160
|
+
Integer($1).chr
|
161
|
+
else
|
162
|
+
if Integer($1) < 65536 and ($KCODE[0] == ?u or $KCODE[0] == ?U)
|
163
|
+
[Integer($1)].pack("U")
|
164
|
+
else
|
165
|
+
"&##{$1};"
|
166
|
+
end
|
167
|
+
end
|
168
|
+
when /\A#x([0-9a-f]+)\z/ni then
|
169
|
+
if $1.hex < 256
|
170
|
+
$1.hex.chr
|
171
|
+
else
|
172
|
+
if $1.hex < 65536 and ($KCODE[0] == ?u or $KCODE[0] == ?U)
|
173
|
+
[$1.hex].pack("U")
|
174
|
+
else
|
175
|
+
"&#x#{$1};"
|
176
|
+
end
|
177
|
+
end
|
178
|
+
else
|
179
|
+
"&#{match};"
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
147
184
|
end
|
148
185
|
end
|
149
186
|
end
|
@@ -33,7 +33,7 @@ module Syrup
|
|
33
33
|
next if account['accountIndex'] == -1
|
34
34
|
|
35
35
|
new_account = Account.new(:id => account['accountIndex'], :institution => self)
|
36
|
-
new_account.name = account['displayName'][/^[^(]*/, 0].strip
|
36
|
+
new_account.name = unescape_html(account['displayName'][/^[^(]*/, 0].strip)
|
37
37
|
new_account.account_number = account['displayName'][/\(([*0-9-]+)\)/, 1]
|
38
38
|
new_account.current_balance = account['current'].to_f
|
39
39
|
new_account.available_balance = account['available'].to_f
|
@@ -85,7 +85,7 @@ module Syrup
|
|
85
85
|
|
86
86
|
transaction = Transaction.new
|
87
87
|
transaction.posted_at = Date.strptime(data[0], '%m/%d/%Y')
|
88
|
-
transaction.payee = data[3]
|
88
|
+
transaction.payee = unescape_html(data[3])
|
89
89
|
transaction.status = :posted # :pending
|
90
90
|
transaction.amount = -parse_currency(data[4]) if data[4].size > 1
|
91
91
|
transaction.amount = parse_currency(data[5]) if data[5].size > 1
|
@@ -28,7 +28,7 @@ module Syrup
|
|
28
28
|
accounts = []
|
29
29
|
json['accountBalance']['depositAccountList'].each do |account|
|
30
30
|
new_account = Account.new(:id => account['accountId'], :institution => self)
|
31
|
-
new_account.name = account['name']
|
31
|
+
new_account.name = unescape_html(account['name'])
|
32
32
|
new_account.account_number = account['number']
|
33
33
|
new_account.current_balance = parse_currency(account['currentAmt'])
|
34
34
|
new_account.available_balance = parse_currency(account['availableAmt'])
|
@@ -38,7 +38,7 @@ module Syrup
|
|
38
38
|
end
|
39
39
|
json['accountBalance']['creditAccountList'].each do |account|
|
40
40
|
new_account = Account.new(:id => account['accountId'], :institution => self)
|
41
|
-
new_account.name = account['name']
|
41
|
+
new_account.name = decode_html_entities(account['name'])
|
42
42
|
new_account.account_number = account['number']
|
43
43
|
new_account.current_balance = parse_currency(account['balanceDueAmt'])
|
44
44
|
new_account.type = :credit
|
@@ -96,7 +96,7 @@ module Syrup
|
|
96
96
|
transaction = Transaction.new
|
97
97
|
|
98
98
|
transaction.posted_at = Date.strptime(data[0], '%m/%d/%Y')
|
99
|
-
transaction.payee = data[2]
|
99
|
+
transaction.payee = decode_html_entities(data[2])
|
100
100
|
transaction.status = data[3].include?("Posted") ? :posted : :pending
|
101
101
|
unless data[4].empty?
|
102
102
|
transaction.amount = -parse_currency(data[4])
|
data/lib/syrup/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: syrup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Don Wilson
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-10-
|
13
|
+
date: 2011-10-11 00:00:00 -06:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|