syrup 0.0.7 → 0.0.8

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.
@@ -54,8 +54,8 @@ module Syrup
54
54
  form = page.form("MAINFORM")
55
55
  form.ddlAccounts = account_id
56
56
  form.ddlType = 0 # 0 = All types of transactions
57
- form.field_with(:id => 'txtFromDate_textBox').value = starting_at.month.to_s + starting_at.strftime('/%e/%Y')
58
- form.field_with(:id => 'txtToDate_textBox').value = ending_at.month.to_s + ending_at.strftime('/%e/%Y')
57
+ form.field_with(:id => 'txtFromDate_textBox').value = starting_at.month.to_s + '/' + starting_at.strftime('%e/%Y').strip
58
+ form.field_with(:id => 'txtToDate_textBox').value = ending_at.month.to_s + '/' + ending_at.strftime('%e/%Y').strip
59
59
  submit_button = form.button_with(:name => 'btnSubmitHistoryRequest')
60
60
  page = form.submit(submit_button)
61
61
 
@@ -67,11 +67,12 @@ module Syrup
67
67
  if first_cell_text.empty?
68
68
  first_cell_text = cell_element.content.strip if cell_element.respond_to? :name
69
69
  else
70
+ content = cell_element.content.strip
70
71
  case first_cell_text
71
72
  when "Available Balance:"
72
- account.available_balance = parse_currency(cell_element.content.strip)
73
+ account.available_balance = parse_currency(content) if content.match(/\d+/)
73
74
  when "Current Balance:"
74
- account.current_balance = parse_currency(cell_element.content.strip)
75
+ account.current_balance = parse_currency(content) if content.match(/\d+/)
75
76
  end
76
77
  end
77
78
  end
@@ -80,15 +81,15 @@ module Syrup
80
81
  # Get all the transactions
81
82
  page.search('#ctlAccountActivityChecking tr').each do |row_element|
82
83
  next if row_element['class'] == 'header'
83
-
84
+
84
85
  data = row_element.css('td').map {|element| element.content.strip }
85
86
 
86
87
  transaction = Transaction.new
87
88
  transaction.posted_at = Date.strptime(data[0], '%m/%d/%Y')
88
89
  transaction.payee = unescape_html(data[3])
89
90
  transaction.status = :posted # :pending
90
- transaction.amount = -parse_currency(data[4]) if data[4].size > 1
91
- transaction.amount = parse_currency(data[5]) if data[5].size > 1
91
+ transaction.amount = -parse_currency(data[4]) if data[4].match(/\d+/)
92
+ transaction.amount = parse_currency(data[5]) if data[5].match(/\d+/)
92
93
 
93
94
  transactions << transaction
94
95
  end
@@ -126,7 +126,7 @@ module Syrup
126
126
  @agent = Mechanize.new
127
127
 
128
128
  # Enter the username
129
- page = agent.get('https://zionsbank.com')
129
+ page = agent.get('https://www.zionsbank.com')
130
130
  form = page.form('logonForm')
131
131
  form.publicCred1 = username
132
132
  page = form.submit
@@ -165,7 +165,11 @@ module Syrup
165
165
  # Clicking this link logs us into the banking.zionsbank.com domain
166
166
  page = page.links.first.click
167
167
 
168
- raise "Unknown URL reached. Try logging in manually through a browser." if page.uri.to_s != "https://banking.zionsbank.com/ibuir/displayUserInterface.htm"
168
+ if page.uri.to_s != "https://banking.zionsbank.com/ibuir/displayUserInterface.htm"
169
+ page = agent.get('https://banking.zionsbank.com/zfnb/userServlet/app/bank/user/viewaccountsbysubtype/viewAccount')
170
+
171
+ raise "Unknown URL reached. Try logging in manually through a browser." if page.body.include?("SessionTimeOutException")
172
+ end
169
173
  end
170
174
 
171
175
  true
@@ -173,4 +177,4 @@ module Syrup
173
177
 
174
178
  end
175
179
  end
176
- end
180
+ end
data/lib/syrup/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Syrup
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
data/syrup.gemspec CHANGED
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
17
17
 
18
18
  s.add_development_dependency "rspec", ">= 2.6.0"
19
19
  s.add_development_dependency "ruby-debug"
20
+ s.add_development_dependency "rake"
20
21
 
21
22
  s.rubyforge_project = s.name
22
23
 
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syrup
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 15
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 7
9
- version: 0.0.7
9
+ - 8
10
+ version: 0.0.8
10
11
  platform: ruby
11
12
  authors:
12
13
  - Don Wilson
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2011-10-16 00:00:00 -06:00
18
+ date: 2012-03-10 23:00:00 -07:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: mechanize
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 23
27
30
  segments:
28
31
  - 1
29
32
  - 0
@@ -35,9 +38,11 @@ dependencies:
35
38
  name: multi_json
36
39
  prerelease: false
37
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
38
42
  requirements:
39
43
  - - ">="
40
44
  - !ruby/object:Gem::Version
45
+ hash: 17
41
46
  segments:
42
47
  - 1
43
48
  - 0
@@ -49,9 +54,11 @@ dependencies:
49
54
  name: rspec
50
55
  prerelease: false
51
56
  requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
52
58
  requirements:
53
59
  - - ">="
54
60
  - !ruby/object:Gem::Version
61
+ hash: 23
55
62
  segments:
56
63
  - 2
57
64
  - 6
@@ -63,14 +70,30 @@ dependencies:
63
70
  name: ruby-debug
64
71
  prerelease: false
65
72
  requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
66
74
  requirements:
67
75
  - - ">="
68
76
  - !ruby/object:Gem::Version
77
+ hash: 3
69
78
  segments:
70
79
  - 0
71
80
  version: "0"
72
81
  type: :development
73
82
  version_requirements: *id004
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ prerelease: false
86
+ requirement: &id005 !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ hash: 3
92
+ segments:
93
+ - 0
94
+ version: "0"
95
+ type: :development
96
+ version_requirements: *id005
74
97
  description: Simple account balance and transactions extractor by scraping bank websites.
75
98
  email:
76
99
  - dontangg@gmail.com
@@ -114,23 +137,27 @@ rdoc_options: []
114
137
  require_paths:
115
138
  - lib
116
139
  required_ruby_version: !ruby/object:Gem::Requirement
140
+ none: false
117
141
  requirements:
118
142
  - - ">="
119
143
  - !ruby/object:Gem::Version
144
+ hash: 3
120
145
  segments:
121
146
  - 0
122
147
  version: "0"
123
148
  required_rubygems_version: !ruby/object:Gem::Requirement
149
+ none: false
124
150
  requirements:
125
151
  - - ">="
126
152
  - !ruby/object:Gem::Version
153
+ hash: 3
127
154
  segments:
128
155
  - 0
129
156
  version: "0"
130
157
  requirements: []
131
158
 
132
159
  rubyforge_project: syrup
133
- rubygems_version: 1.3.6
160
+ rubygems_version: 1.6.2
134
161
  signing_key:
135
162
  specification_version: 3
136
163
  summary: Simple account balance and transactions extractor.