ba 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ config/config.yml
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use ruby-1.9.3-p385
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ba.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Li Ellis Gallardo
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,56 @@
1
+ # Ba [![Build Status](https://travis-ci.org/lellisga/ba_gem.png)](https://travis-ci.org/lellisga/ba_gem)
2
+
3
+ Bank Account Gem!
4
+
5
+ This Gem was created to help you get information from
6
+ your bank account from your console
7
+
8
+ ## Currently Supported Banks
9
+ Bancolombia
10
+ Payoneer (work in progress)
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ gem 'ba'
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install ba
25
+
26
+ ## Usage
27
+
28
+ ### Checkout the different commands by running
29
+ $ ba
30
+
31
+ ### Install
32
+ Run the following command if you don't have any config/config.yml file in your local path
33
+
34
+ $ ba install
35
+
36
+ ### Modify the ~/config/config.yml with your bank info
37
+ $ vi ~/config/config.yml
38
+
39
+ ### Run the command for your bank
40
+ $ ba [BANK] balance
41
+
42
+ ## Contributing
43
+
44
+ 1. Fork it
45
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
46
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
47
+ 4. Push to the branch (`git push origin my-new-feature`)
48
+ 5. Create new Pull Request
49
+
50
+ ### Adding new Scripts
51
+ - Follow the bank.sample.rb example
52
+ - Add the bank to the config/config.sample.yml
53
+ - Push it!
54
+
55
+ ## CONTRIBUTORS
56
+ Bancolombia Script => Jean Pierre(@gomayonqui)
@@ -0,0 +1,19 @@
1
+ require 'bundler'
2
+ require "rake/testtask"
3
+ require 'rspec/core/rake_task'
4
+
5
+ Bundler::GemHelper.install_tasks
6
+
7
+ Rake::TestTask.new do |t|
8
+ t.libs << "test"
9
+ t.pattern = "test/**/*_test.rb"
10
+ t.verbose = false
11
+ end
12
+
13
+ RSpec::Core::RakeTask.new(:spec) do |t|
14
+ t.pattern = "spec/**/*_spec.rb"
15
+ t.rspec_opts = "--color"
16
+ t.verbose = false
17
+ end
18
+
19
+ task :default => [:test, :spec]
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ba/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ba"
8
+ spec.version = Ba::VERSION
9
+ spec.authors = ["Li Ellis Gallardo"]
10
+ spec.email = ["lellisga@gmail.com"]
11
+ spec.description = %q{BankBalance Gem is used to check your bank account balance}
12
+ spec.summary = %q{Checking your bank account is now much faster}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "thor"
22
+ spec.add_dependency "mechanize"
23
+ spec.add_dependency "highline"
24
+ spec.add_dependency "fileutils"
25
+ spec.add_development_dependency "bundler", "~> 1.3"
26
+ spec.add_development_dependency "rake"
27
+ spec.add_development_dependency "rspec"
28
+ spec.add_development_dependency "pry"
29
+
30
+ spec.post_install_message = "Important: You don't need any configuration file\n\n"
31
+ end
data/bin/ba ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ Signal.trap("INT") { exit 1 }
4
+ require 'ba'
5
+
6
+ Ba::CLI.start(ARGV)
@@ -0,0 +1,4 @@
1
+ bancolombia:
2
+ username: sampleusername
3
+ password: samplepassword
4
+ payoneer:
@@ -0,0 +1,5 @@
1
+ require "ba/version"
2
+ require "ba/cli"
3
+
4
+ module Ba
5
+ end
@@ -0,0 +1,2 @@
1
+ # LOAD THE BANKS
2
+ Dir[File.join("#{File.dirname(__FILE__)}/banks/**.rb")].each { |f| require f }
@@ -0,0 +1,61 @@
1
+ module Ba::Banks
2
+ class Bancolombia < Thor
3
+
4
+ desc "balance", "Returns the Bancolombia account balance"
5
+ def balance
6
+ ##Login username page
7
+ agent.get("https://bancolombia.olb.todo1.com/olb/Init")
8
+ userLoginPage = agent.get("https://bancolombia.olb.todo1.com/olb/Login")
9
+ userLoginPage.form_with(:name => "authenticationForm") do |f|
10
+ f.userId = ask("Username: ")
11
+ end.click_button
12
+
13
+ ##Redirect to password page
14
+ passwordPage = agent.get("https://bancolombia.olb.todo1.com/olb/GetUserProfile")
15
+ passwordPageHtml = passwordPage.body
16
+ ##Insert \r for correct regex on password scripts
17
+ passwordPageHtml.gsub!(/document.getElementById/, "\r\n\t document.getElementById")
18
+ enc_password = ""
19
+ password = ask("Password: ") { |q| q.echo = "*" }
20
+ password.to_s.split('').each do |n|
21
+ passwordPageHtml.match(/\'td_#{n}\'\)\.addEventListener\(\'click\'\,\sfunction\(\)\{\S*\(\"(.*)\"\)\;\}/);
22
+ enc_password << $1
23
+ end
24
+
25
+ ##Capture secret hidden field
26
+ passwordPageHtml.match(/'PASSWORD\':\'(.*)\'/)
27
+ secretHiddenField = $1
28
+
29
+ ##Post encripted password and secret hidden field
30
+ passwordPage.form_with(:name => "authenticationForm") do |f|
31
+ f.userId = "0"
32
+ f.password = enc_password
33
+ f.add_field!(secretHiddenField, value = enc_password)
34
+ end.click_button
35
+
36
+ ##Get Balance
37
+ page = agent.get("https://bancolombia.olb.todo1.com/olb/Authentication")
38
+ process_questions(page) if page.forms_with(name: "checkChallQuestForm").any?
39
+ balancePage = agent.get("/olb/BeginInitializeActionFromCM?from=pageTabs")
40
+ balance = balancePage.search(".contentTotalNegrita").last.children.text
41
+ puts "Your actual balance is: $#{balance}"
42
+ end
43
+
44
+ private
45
+
46
+ def process_questions(page)
47
+ puts "The answer for the following questions will not be saved"
48
+ answer_one = ask(page.search("#luserAnswer1").text.strip + " ") { |q| q.echo = "*" }
49
+ answer_two = ask(page.search("#luserAnswer2").text.strip + " ") { |q| q.echo = "*" }
50
+ form = page.form_with(name: "checkChallQuestForm") do |f|
51
+ f.userAnswer1 = answer_one
52
+ f.userAnswer2 = answer_two
53
+ end
54
+ form.submit(form.buttons_with(name: "accept_btn").first)
55
+ end
56
+
57
+ def agent
58
+ @agent ||= Mechanize.new
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,15 @@
1
+ # module Ba::Banks
2
+ # class BankSample < Thor
3
+ #
4
+ # desc "balance", "Returns the [BANK] account balance"
5
+ # def balance
6
+ # puts "Not yet Implemented"
7
+ # end
8
+ #
9
+ # private
10
+ #
11
+ # def config
12
+ # @config ||= YAML::load(File.open('config/config.yml'))["BANK"]
13
+ # end
14
+ # end
15
+ # end
@@ -0,0 +1,15 @@
1
+ module Ba::Banks
2
+ class Payoneer < Thor
3
+
4
+ desc "balance", "Returns the Payoneer account balance"
5
+ def balance
6
+ puts "Not yet Implemented"
7
+ end
8
+
9
+ private
10
+
11
+ def config
12
+ @config ||= YAML::load(File.open('config/config.yml'))["payoneer"]
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,25 @@
1
+ require 'thor'
2
+ require 'yaml'
3
+ require 'mechanize'
4
+ require 'highline/import'
5
+ require 'ba/banks'
6
+
7
+ module Ba
8
+ class CLI < Thor
9
+ include Banks
10
+
11
+ # Add the banks located in the ba/banks directory to the command line menu
12
+ Ba::Banks.constants.each do |bank|
13
+ bank_class = Ba::Banks.const_get(bank)
14
+ sub_command = bank.downcase
15
+ register(bank_class, sub_command, "#{sub_command} [COMMAND]", "#{bank} Bank usage.")
16
+ end
17
+
18
+ desc "version", "Returns the Application version"
19
+ def version
20
+ puts Ba::VERSION
21
+ end
22
+
23
+ map "-v" => :version
24
+ end
25
+ end
@@ -0,0 +1,3 @@
1
+ module Ba
2
+ VERSION = "0.0.7"
3
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ba::CLI do
4
+ context "Including new scrapers" do
5
+ context "when Bancolombia bank in the bank.yml file" do
6
+ it "respond to bancolombia" do
7
+ expect(subject).to respond_to "bancolombia"
8
+ end
9
+ end
10
+
11
+ context "when Payoneer bank is in the bank.yml file" do
12
+ it "respond to payoneer" do
13
+ expect(subject).to respond_to "payoneer"
14
+ end
15
+ end
16
+ end
17
+
18
+ describe "#version" do
19
+ it "returns the current application version" do
20
+ STDOUT.should_receive(:puts).with ("0.0.6")
21
+ subject.version
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ba do
4
+ describe "#version" do
5
+ it "includes a version" do
6
+ Ba::VERSION.should_not be_nil
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,2 @@
1
+ require_relative '../lib/ba'
2
+ require_relative '../lib/ba/cli'
@@ -0,0 +1,15 @@
1
+ require_relative '../../test_helper'
2
+
3
+ describe Ba::CLI do
4
+ describe "when Bancolombia bank in the bank.yml file" do
5
+ it "respond to bancolombia" do
6
+ assert_respond_to Ba::CLI.new, "bancolombia"
7
+ end
8
+ end
9
+
10
+ describe "when Payoneer bank is in the bank.yml file" do
11
+ it "respond to payoneer" do
12
+ assert_respond_to Ba::CLI.new, "payoneer"
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,7 @@
1
+ require_relative '../../test_helper'
2
+
3
+ describe Ba do
4
+ it "must be defined" do
5
+ Ba::VERSION.wont_be_nil
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ require 'minitest/autorun'
2
+ require 'minitest/pride'
3
+ require_relative '../lib/ba'
metadata ADDED
@@ -0,0 +1,206 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ba
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.7
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Li Ellis Gallardo
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: thor
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: mechanize
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: highline
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: fileutils
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: bundler
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '1.3'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '1.3'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rake
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: rspec
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: pry
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ description: BankBalance Gem is used to check your bank account balance
143
+ email:
144
+ - lellisga@gmail.com
145
+ executables:
146
+ - ba
147
+ extensions: []
148
+ extra_rdoc_files: []
149
+ files:
150
+ - .gitignore
151
+ - .rvmrc
152
+ - Gemfile
153
+ - LICENSE.txt
154
+ - README.md
155
+ - Rakefile
156
+ - ba.gemspec
157
+ - bin/ba
158
+ - config/config.sample.yml
159
+ - lib/ba.rb
160
+ - lib/ba/banks.rb
161
+ - lib/ba/banks/bancolombia.rb
162
+ - lib/ba/banks/bank.sample.rb
163
+ - lib/ba/banks/payoneer.rb
164
+ - lib/ba/cli.rb
165
+ - lib/ba/version.rb
166
+ - spec/lib/ba/cli_spec.rb
167
+ - spec/lib/ba/version_spec.rb
168
+ - spec/spec_helper.rb
169
+ - test/lib/ba/cli_test.rb
170
+ - test/lib/ba/version_test.rb
171
+ - test/test_helper.rb
172
+ homepage: ''
173
+ licenses:
174
+ - MIT
175
+ post_install_message: ! 'Important: You don''t need any configuration file
176
+
177
+
178
+ '
179
+ rdoc_options: []
180
+ require_paths:
181
+ - lib
182
+ required_ruby_version: !ruby/object:Gem::Requirement
183
+ none: false
184
+ requirements:
185
+ - - ! '>='
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ required_rubygems_version: !ruby/object:Gem::Requirement
189
+ none: false
190
+ requirements:
191
+ - - ! '>='
192
+ - !ruby/object:Gem::Version
193
+ version: '0'
194
+ requirements: []
195
+ rubyforge_project:
196
+ rubygems_version: 1.8.25
197
+ signing_key:
198
+ specification_version: 3
199
+ summary: Checking your bank account is now much faster
200
+ test_files:
201
+ - spec/lib/ba/cli_spec.rb
202
+ - spec/lib/ba/version_spec.rb
203
+ - spec/spec_helper.rb
204
+ - test/lib/ba/cli_test.rb
205
+ - test/lib/ba/version_test.rb
206
+ - test/test_helper.rb