ba 0.0.8 → 0.0.9

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.
data/ba.gemspec CHANGED
@@ -6,8 +6,8 @@ require 'ba/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "ba"
8
8
  spec.version = Ba::VERSION
9
- spec.authors = ["Li Ellis Gallardo"]
10
- spec.email = ["lellisga@gmail.com"]
9
+ spec.authors = ["Li Ellis Gallardo", "Jean Pierre Guarin"]
10
+ spec.email = ["lellisga@gmail.com", "escribimepues@gmail.com"]
11
11
  spec.description = %q{BankBalance Gem is used to check your bank account balance}
12
12
  spec.summary = %q{Checking your bank account is now much faster}
13
13
  spec.homepage = ""
@@ -1,38 +1,30 @@
1
+ require 'ba/helpers/bancolombia_helper'
2
+
1
3
  module Ba::Banks
2
4
  class Bancolombia < Thor
5
+ include Ba::Helpers::BancolombiaHelper
3
6
 
4
7
  desc "balance optional: [username] [password]", "Returns the Bancolombia account balance"
5
8
  def balance(username = nil , password = nil)
6
9
  go_to_root
7
10
  process_username_authentication(username)
8
11
  process_password_authentication(password)
9
- page = go_to_authentication_path
10
- process_questions(page) if need_to_answer_banks_questions?(page)
11
- balancePage = agent.get("/olb/BeginInitializeActionFromCM?from=pageTabs")
12
- balance = balancePage.search(".contentTotalNegrita").last.children.text
13
- puts "Your actual balance is: $#{balance}"
12
+ process_questions if need_to_answer_banks_questions?
13
+ puts "Your actual balance is: $#{get_balance}"
14
14
  end
15
15
 
16
16
  private
17
17
 
18
- def go_to_authentication_path
19
- agent.get("https://bancolombia.olb.todo1.com/olb/Authentication")
20
- end
21
-
22
- def need_to_answer_banks_questions?(page)
23
- !get_question_form(page).nil?
24
- end
25
-
26
- def get_question_form(page)
27
- @question_form ||= page.form_with(name: "checkChallQuestForm")
18
+ def get_balance
19
+ get_balance_page.search(".contentTotalNegrita").last.children.text
28
20
  end
29
21
 
30
22
  def process_password_authentication(password)
31
- passwordPageHtml = get_password_path.body
23
+ passwordPageHtml = password_path_body
32
24
  ##Insert \r for correct regex on password scripts
33
25
  passwordPageHtml.gsub!(/document.getElementById/, "\r\n\t document.getElementById")
34
26
  enc_password = ""
35
- password = password || ask("Password: ")
27
+ password = password || get_password
36
28
  password.to_s.split('').each do |n|
37
29
  passwordPageHtml.match(/\'td_#{n}\'\)\.addEventListener\(\'click\'\,\sfunction\(\)\{\S*\(\"(.*)\"\)\;\}/)
38
30
  enc_password << $1
@@ -53,47 +45,20 @@ module Ba::Banks
53
45
  end
54
46
 
55
47
  def process_username_authentication(username)
56
- form = get_login_path.form_with(name: "authenticationForm") do |f|
57
- f.userId = username || ask("Username: ")
58
- end
59
-
48
+ form = login_path_form(username)
60
49
  form.click_button
61
50
  end
62
-
63
- def go_to_root
64
- agent.get "https://bancolombia.olb.todo1.com/olb/Init"
65
- end
66
51
 
67
- def get_login_path
68
- agent.get "https://bancolombia.olb.todo1.com/olb/Login"
69
- end
70
-
71
- def get_password_path
72
- @password_path ||= agent.get("https://bancolombia.olb.todo1.com/olb/GetUserProfile")
73
- end
74
-
75
- def process_questions(page)
52
+ def process_questions
76
53
  puts "The answer for the following questions will not be saved"
77
- first_question = first_question(page)
78
- second_question = second_question(page)
54
+ first_question = first_question
55
+ second_question = second_question
79
56
 
80
- form = get_question_form(page) do |f|
57
+ form = get_question_form do |f|
81
58
  f.userAnswer1 = first_question
82
59
  f.userAnswer2 = secound_question
83
60
  end
84
61
  agent.submit(form)
85
62
  end
86
-
87
- def first_question(page)
88
- ask(page.search("#luserAnswer1").text.strip)
89
- end
90
-
91
- def second_question(page)
92
- ask(page.search("#luserAnswer2").text.strip)
93
- end
94
-
95
- def agent
96
- @agent ||= Mechanize.new
97
- end
98
63
  end
99
64
  end
@@ -0,0 +1,64 @@
1
+ module Ba
2
+ module Helpers
3
+ module BancolombiaHelper
4
+ private
5
+ def go_to_authentication_path
6
+ @auth_path ||= agent.get("https://bancolombia.olb.todo1.com/olb/Authentication")
7
+ end
8
+
9
+ def need_to_answer_banks_questions?
10
+ !get_question_form.nil?
11
+ end
12
+
13
+ def get_question_form
14
+ @question_form ||= go_to_authentication_path.form_with(name: "checkChallQuestForm")
15
+ end
16
+
17
+ def go_to_root
18
+ agent.get "https://bancolombia.olb.todo1.com/olb/Init"
19
+ end
20
+
21
+ def login_path
22
+ agent.get "https://bancolombia.olb.todo1.com/olb/Login"
23
+ end
24
+
25
+ def login_path_form(username)
26
+ login_path.form_with(name: "authenticationForm") do |f|
27
+ f.userId = username || get_username
28
+ end
29
+ end
30
+
31
+ def get_password_path
32
+ @password_path ||= agent.get("https://bancolombia.olb.todo1.com/olb/GetUserProfile")
33
+ end
34
+
35
+ def password_path_body
36
+ get_password_path.body
37
+ end
38
+
39
+ def get_username
40
+ ask("Username: ")
41
+ end
42
+
43
+ def get_password
44
+ ask("Password: ") { |q| q.echo = false }
45
+ end
46
+
47
+ def first_question
48
+ ask(go_to_authentication_path.search("#luserAnswer1").text.strip)
49
+ end
50
+
51
+ def second_question(page)
52
+ ask(go_to_authentication_path.search("#luserAnswer2").text.strip)
53
+ end
54
+
55
+ def get_balance_page
56
+ balancePage = agent.get("/olb/BeginInitializeActionFromCM?from=pageTabs")
57
+ end
58
+
59
+ def agent
60
+ @agent ||= Mechanize.new
61
+ end
62
+ end
63
+ end
64
+ end
@@ -1,3 +1,3 @@
1
1
  module Ba
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -17,7 +17,7 @@ describe Ba::CLI do
17
17
 
18
18
  describe "#version" do
19
19
  it "returns the current application version" do
20
- STDOUT.should_receive(:puts).with ("0.0.8")
20
+ STDOUT.should_receive(:puts).with ("0.0.9")
21
21
  subject.version
22
22
  end
23
23
  end
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ba
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Li Ellis Gallardo
9
+ - Jean Pierre Guarin
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2013-03-30 00:00:00.000000000 Z
13
+ date: 2013-04-01 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: thor
@@ -142,6 +143,7 @@ dependencies:
142
143
  description: BankBalance Gem is used to check your bank account balance
143
144
  email:
144
145
  - lellisga@gmail.com
146
+ - escribimepues@gmail.com
145
147
  executables:
146
148
  - ba
147
149
  extensions: []
@@ -162,6 +164,7 @@ files:
162
164
  - lib/ba/banks/bank.sample.rb
163
165
  - lib/ba/banks/payoneer.rb
164
166
  - lib/ba/cli.rb
167
+ - lib/ba/helpers/bancolombia_helper.rb
165
168
  - lib/ba/version.rb
166
169
  - spec/lib/ba/cli_spec.rb
167
170
  - spec/lib/ba/version_spec.rb