fine_ants 1.3.0 → 1.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bdfd25caa322ccfb9cadc91f34bbe37193220c56
4
- data.tar.gz: 32edb4b9d2e7d33dcda39819df4cb01167f0d8e9
3
+ metadata.gz: 071fd57f7af644d446d6ebcb23ee806b1035caf9
4
+ data.tar.gz: 6d546e676ff383d2e3a64630dd3ec5242c0c59e6
5
5
  SHA512:
6
- metadata.gz: 8266c49f0559ca3a1207f01c8423f72eddbc3fe469cf310437c60acae857b55d211f4af3bfa02eddd94444c3fcf975d9a9f3bad451ecfd695f0021f53376f877
7
- data.tar.gz: 20df6842aec3549e9a84a46d5ff22351aaedb181c47d07b32a4767bec156475c6eb5f973b6b316a99f3607ac74e0b485cb03ca3d6f8532f1d4ab821f7b4377f9
6
+ metadata.gz: 143e892128f919a23587e25bc74f314255cc133814a8fb5d4e42328b208876ebac57bc8560219e80f5c79fb7e8e4625d5ce2907108370fe58db32e6145d7bdba
7
+ data.tar.gz: ac5d4192b60073153573890b5698ed26a213ebb054cd69b733fa02f7e770116a2e1a44ae40ef0c7c1d0e7ad264b7dcafe6508550af54cd3b15206bb9d39fedd6
data/README.md CHANGED
@@ -57,12 +57,16 @@ when a login process requires a 2FA challenge.
57
57
 
58
58
  Right now, FineAnts ships with adapters for:
59
59
 
60
- * [Vanguard Personal Investment](https://personal.vanguard.com/us/hnwnesc/nesc/LoginPage)
61
- * [PNC Personal Banking](https://www.pnc.com/en/personal-banking.html)
62
- * [Betterment](https://www.betterment.com)
63
- * [Chase](https://www.chase.com)
64
- * [Simple](https://www.simple.com)
65
- * [Target REDcard](https://rcam.target.com)
60
+ | Name | Adapter Name |
61
+ | --------------------------------------------------------------------------------------- | ----------------- |
62
+ | [Vanguard Personal Investment](https://personal.vanguard.com/us/hnwnesc/nesc/LoginPage) | `:vanguard` |
63
+ | [PNC Personal Banking](https://www.pnc.com/en/personal-banking.html) | `:pnc` |
64
+ | [Betterment](https://www.betterment.com) | `:betterment` |
65
+ | [Chase](https://www.chase.com) | `:chase` |
66
+ | [Simple (BBVA)](https://www.simple.com) | `:simple` |
67
+ | [Simple (Bancorp)](https://www.simple.com) | `:simple_bancorp` |
68
+ | [Target REDcard](https://rcam.target.com) | `:target` |
69
+ | [Purdue Federal Credit Union](https://www.purduefed.com) | `:purduefed` |
66
70
 
67
71
  You can also implement your own adapter and pass it to `FineAnts.download`. The
68
72
  expected public contract of an adapter is:
@@ -10,9 +10,15 @@ module FineAnts
10
10
 
11
11
  def login
12
12
  visit "https://www.chase.com"
13
- fill_in "User name", :with => @user
14
- fill_in "Password", :with => @password
15
- click_link "Sign in"
13
+ within_frame(find("#logonbox")) do
14
+ fill_in "Username", :with => @user
15
+ fill_in "Password", :with => @password
16
+ # I'm not happy with this. Chase's site seems to blank out the
17
+ # username and password fields if you hit "Sign in" immediately after
18
+ # the dialog appears. We're sleeping to sidestep this behavior.
19
+ sleep 0.1
20
+ click_on "Sign in"
21
+ end
16
22
  verify_login!
17
23
  end
18
24
 
@@ -54,7 +60,7 @@ module FineAnts
54
60
  private
55
61
 
56
62
  def parse_currency(currency_string)
57
- BigDecimal.new(currency_string.match(/\$(.*)$/)[1].gsub(/,/,''))
63
+ BigDecimal.new(currency_string.match(/\$(.*)$/)[1].delete(","))
58
64
  end
59
65
 
60
66
  def parse_due_date(due_date_string)
@@ -0,0 +1,76 @@
1
+ require "bigdecimal"
2
+
3
+ module FineAnts
4
+ module Adapters
5
+ class Purduefed
6
+ def initialize(credentials)
7
+ @user = credentials[:user]
8
+ @password = credentials[:password]
9
+ end
10
+
11
+ def login
12
+ visit "https://www.purduefed.com"
13
+ fill_in "USERNAME", with: @user
14
+ click_button "Login"
15
+ fill_in "M_content_PCDZ_MF3KFEF_ctl00_Password", with: @password
16
+ click_button "Sign in"
17
+ end
18
+
19
+ def download
20
+ deposit_table = find("span", text: /Deposit Accounts/)
21
+ .find(:xpath, "../..")
22
+ .find(".module_container")
23
+ loan_table = find("span", text: /Loans/)
24
+ .find(:xpath, "../..")
25
+ .find(".module_container")
26
+ deposit_transactions = process_table(deposit_table)
27
+ loan_transactions = process_table(loan_table, type: :loan)
28
+
29
+ deposit_transactions + loan_transactions
30
+ end
31
+
32
+ private
33
+
34
+ def verify_login!
35
+ find "Welcome, "
36
+ rescue Capybara::ElementNotFound
37
+ raise FineAnts::LoginFailedError
38
+ end
39
+
40
+ def process_table(table, type: :deposit)
41
+ transaction_rows(table) do |row|
42
+ cells = row.all("td")
43
+ amount = parse_currency(cells[1].text)
44
+ amount = -amount if type == :loan
45
+ name = cells[0].find("a").text
46
+
47
+ {
48
+ adapter: :purduefed,
49
+ user: @user,
50
+ id: name,
51
+ name: name,
52
+ type: type,
53
+ amount: amount,
54
+ available_amount: parse_currency(cells[2].text)
55
+ }
56
+ end
57
+ end
58
+
59
+ def transaction_rows(table)
60
+ return [] if empty_table?(table)
61
+
62
+ table.all("tr")[1..-2].map do |row|
63
+ yield row
64
+ end
65
+ end
66
+
67
+ def parse_currency(currency_string)
68
+ BigDecimal.new(currency_string.match(/\$(.*)$/)[1].delete(","))
69
+ end
70
+
71
+ def empty_table?(table)
72
+ table.all("tr")[1..-2].map(&:text).first == "No accounts to be displayed."
73
+ end
74
+ end
75
+ end
76
+ end
@@ -19,9 +19,9 @@ module FineAnts
19
19
  end
20
20
 
21
21
  def download
22
- balance = find(".sts-available").find("b").text
23
- available_balance = find("#sts-flag").text.strip
24
22
  user_name = find(".masthead-username").text
23
+ balance = find_all(".balances-item-value").first.text
24
+ available_balance = find(".balances-sts .amount").text.strip
25
25
 
26
26
  [
27
27
  {
@@ -41,7 +41,7 @@ module FineAnts
41
41
  end
42
42
 
43
43
  def parse_currency(currency_string)
44
- BigDecimal.new(currency_string.match(/\$?(.*)$/)[1].gsub(/,/,''))
44
+ BigDecimal.new(currency_string.match(/\$?(.*)$/)[1].delete(","))
45
45
  end
46
46
 
47
47
  def verify_login!
@@ -0,0 +1,55 @@
1
+ require "bigdecimal"
2
+
3
+ module FineAnts
4
+ module Adapters
5
+ class SimpleBancorp
6
+ def initialize(credentials)
7
+ @user = credentials[:user]
8
+ @password = credentials[:password]
9
+ end
10
+
11
+ def login
12
+ visit "https://www.simple.com"
13
+ click_link "Log In"
14
+
15
+ fill_in "username", :with => @user
16
+ fill_in "passphrase", :with => @password
17
+ click_button "Sign in"
18
+ verify_login!
19
+ end
20
+
21
+ def download
22
+ balance = find(".sts-available").find("b").text
23
+ available_balance = find("#sts-flag").text.strip
24
+ user_name = find(".masthead-username").text
25
+
26
+ [
27
+ {
28
+ :adapter => :simple_bancorp,
29
+ :user => @user,
30
+ :id => "#{user_name}",
31
+ :name => "#{user_name}",
32
+ :amount => parse_currency(balance),
33
+ :available_amount => parse_currency(available_balance),
34
+ }
35
+ ].tap{ logout! }
36
+ end
37
+
38
+ private
39
+ def logout!
40
+ visit "https://bank.simple.com/signout"
41
+ end
42
+
43
+ def parse_currency(currency_string)
44
+ BigDecimal.new(currency_string.match(/\$?(.*)$/)[1].gsub(/,/,''))
45
+ end
46
+
47
+ def verify_login!
48
+ find("h2", text: "Safe-to-Spend")
49
+ rescue Capybara::ElementNotFound
50
+ raise FineAnts::LoginFailedError.new
51
+ end
52
+ end
53
+ end
54
+ end
55
+
@@ -1,3 +1,3 @@
1
1
  module FineAnts
2
- VERSION = "1.3.0"
2
+ VERSION = "1.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fine_ants
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Searls
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-01 00:00:00.000000000 Z
11
+ date: 2017-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -100,7 +100,9 @@ files:
100
100
  - lib/fine_ants/adapters/betterment.rb
101
101
  - lib/fine_ants/adapters/chase.rb
102
102
  - lib/fine_ants/adapters/pnc.rb
103
+ - lib/fine_ants/adapters/purduefed.rb
103
104
  - lib/fine_ants/adapters/simple.rb
105
+ - lib/fine_ants/adapters/simple_bancorp.rb
104
106
  - lib/fine_ants/adapters/target.rb
105
107
  - lib/fine_ants/adapters/vanguard.rb
106
108
  - lib/fine_ants/capybara_setup.rb
@@ -126,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
128
  version: '0'
127
129
  requirements: []
128
130
  rubyforge_project:
129
- rubygems_version: 2.5.1
131
+ rubygems_version: 2.5.2
130
132
  signing_key:
131
133
  specification_version: 4
132
134
  summary: Opens your browser and finds your bank account status.