cartolify 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +45 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +18 -0
- data/Rakefile +46 -0
- data/VERSION +1 -0
- data/lib/cartolify/account.rb +0 -0
- data/lib/cartolify/bank.rb +26 -0
- data/lib/cartolify/banks/bci_bank.rb +90 -0
- data/lib/cartolify/banks/bci_mobi_bank.rb +78 -0
- data/lib/cartolify/banks/chileempresas_bank.rb +116 -0
- data/lib/cartolify/transaction.rb +18 -0
- data/lib/cartolify.rb +6 -0
- data/test/helper.rb +28 -0
- data/test/test_bank.rb +33 -0
- data/test/test_bci_bank.rb +36 -0
- data/test/test_cartolify.rb +7 -0
- metadata +145 -0
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "rdoc", "~> 3.12"
|
10
|
+
gem "bundler", "~> 1.0.0"
|
11
|
+
gem "jeweler", "~> 1.8.3"
|
12
|
+
gem "turn"
|
13
|
+
end
|
14
|
+
|
15
|
+
gem 'mechanize'
|
16
|
+
gem 'nokogiri'
|
17
|
+
gem 'json'
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
ansi (1.4.1)
|
5
|
+
domain_name (0.5.2)
|
6
|
+
unf (~> 0.0.3)
|
7
|
+
git (1.2.5)
|
8
|
+
jeweler (1.8.3)
|
9
|
+
bundler (~> 1.0)
|
10
|
+
git (>= 1.2.5)
|
11
|
+
rake
|
12
|
+
rdoc
|
13
|
+
json (1.6.5)
|
14
|
+
mechanize (2.1)
|
15
|
+
domain_name (~> 0.5, >= 0.5.1)
|
16
|
+
net-http-digest_auth (~> 1.1, >= 1.1.1)
|
17
|
+
net-http-persistent (~> 2.3, >= 2.3.2)
|
18
|
+
nokogiri (~> 1.4)
|
19
|
+
ntlm-http (~> 0.1, >= 0.1.1)
|
20
|
+
webrobots (~> 0.0, >= 0.0.9)
|
21
|
+
net-http-digest_auth (1.2)
|
22
|
+
net-http-persistent (2.4)
|
23
|
+
nokogiri (1.5.0)
|
24
|
+
ntlm-http (0.1.1)
|
25
|
+
rake (0.9.2.2)
|
26
|
+
rdoc (3.12)
|
27
|
+
json (~> 1.4)
|
28
|
+
turn (0.8.2)
|
29
|
+
ansi (>= 1.2.2)
|
30
|
+
unf (0.0.4)
|
31
|
+
unf_ext
|
32
|
+
unf_ext (0.0.4)
|
33
|
+
webrobots (0.0.13)
|
34
|
+
|
35
|
+
PLATFORMS
|
36
|
+
ruby
|
37
|
+
|
38
|
+
DEPENDENCIES
|
39
|
+
bundler (~> 1.0.0)
|
40
|
+
jeweler (~> 1.8.3)
|
41
|
+
json
|
42
|
+
mechanize
|
43
|
+
nokogiri
|
44
|
+
rdoc (~> 3.12)
|
45
|
+
turn
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Patricio Bruna
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
= Cartolify
|
2
|
+
|
3
|
+
Cartolify is a Library, and the main engine, of my new project for keep tracks of my budget.
|
4
|
+
This library has 3 functions:
|
5
|
+
|
6
|
+
* Return the Bank Account Balance,
|
7
|
+
* Return the last month transactions list, and
|
8
|
+
* Sync the transactions with a local DB
|
9
|
+
|
10
|
+
== Contributing to cartolify
|
11
|
+
|
12
|
+
For now is not possible, beacuse we are just starting
|
13
|
+
|
14
|
+
== Copyright
|
15
|
+
|
16
|
+
Copyright (c) 2012 Patricio Bruna. See LICENSE.txt for
|
17
|
+
further details.
|
18
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "cartolify"
|
18
|
+
gem.homepage = "http://github.com/pbruna/cartolify"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{ Lib for getting info of Chilean Banks}
|
21
|
+
gem.description = %Q{This is the Engine for my Budget System}
|
22
|
+
gem.email = "pbruna@gmail.com"
|
23
|
+
gem.authors = ["Patricio Bruna"]
|
24
|
+
gem.version = File.exist?('VERSION') ? File.read('VERSION') : "0.0"
|
25
|
+
# dependencies defined in Gemfile
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
require 'rake/testtask'
|
30
|
+
Rake::TestTask.new(:test) do |test|
|
31
|
+
test.libs << 'lib' << 'test'
|
32
|
+
test.pattern = 'test/**/test_*.rb'
|
33
|
+
test.verbose = true
|
34
|
+
end
|
35
|
+
|
36
|
+
task :default => :test
|
37
|
+
|
38
|
+
require 'rdoc/task'
|
39
|
+
Rake::RDocTask.new do |rdoc|
|
40
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : "0.1"
|
41
|
+
|
42
|
+
rdoc.rdoc_dir = 'rdoc'
|
43
|
+
rdoc.title = "cartolify #{version}"
|
44
|
+
rdoc.rdoc_files.include('README*')
|
45
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
46
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1
|
File without changes
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class Bank
|
2
|
+
attr_reader :branch
|
3
|
+
|
4
|
+
def initialize(bank_class, bank_account)
|
5
|
+
require "cartolify/banks/#{bank_class.downcase}_bank"
|
6
|
+
@branch = Object.const_get("#{bank_class.upcase}Bank").new(bank_account)
|
7
|
+
end
|
8
|
+
|
9
|
+
def url
|
10
|
+
@branch.url
|
11
|
+
end
|
12
|
+
|
13
|
+
def balance
|
14
|
+
@branch.balance
|
15
|
+
end
|
16
|
+
|
17
|
+
def session
|
18
|
+
@branch.session
|
19
|
+
end
|
20
|
+
|
21
|
+
def transactions
|
22
|
+
@branch.transactions
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class BCIBank < Bank
|
4
|
+
attr_accessor :user, :password, :account_number
|
5
|
+
attr_reader :session
|
6
|
+
|
7
|
+
URL = "https://www.bci.cl/cl/bci/aplicaciones/seguridad/autenticacion/loginPersonas.jsf"
|
8
|
+
LOGIN_FORM_NAME = "frm"
|
9
|
+
BROWSER = "Mac FireFox"
|
10
|
+
START_URL = "https://www.bci.cl/cuentaswls/ControladorCuentas?opcion=CTACTECARTOLA&objeto="
|
11
|
+
|
12
|
+
def initialize(account = {})
|
13
|
+
@user = account[:user]
|
14
|
+
@password = account[:password]
|
15
|
+
@account_number = account[:number]
|
16
|
+
@session = new_session
|
17
|
+
end
|
18
|
+
|
19
|
+
def url
|
20
|
+
URL
|
21
|
+
end
|
22
|
+
|
23
|
+
def balance
|
24
|
+
# We make sure we are on the first page
|
25
|
+
session.get("#{START_URL}#{self.account_number}")
|
26
|
+
# The balance is in the 7 table, second td
|
27
|
+
string_balance = session.page.root.css("table")[6].css("td")[1].text
|
28
|
+
# Remove de $ simbol and the dots
|
29
|
+
convert_money_to_integer(string_balance)
|
30
|
+
end
|
31
|
+
|
32
|
+
def transactions
|
33
|
+
transactions = []
|
34
|
+
# We go to the transactions page
|
35
|
+
session.get("#{START_URL}#{self.account_number}")
|
36
|
+
# Tables that hold the transactions, we select the tr's
|
37
|
+
table_rows = session.page.root.css("table")[10].css("tr.blanco, tr.suave")
|
38
|
+
table_rows.each do |row|
|
39
|
+
values = row.css("td").map { |td| clean_string(td) }
|
40
|
+
total = values[3].size > 0 ? values[3] : values[4]
|
41
|
+
|
42
|
+
transaccion_info = {
|
43
|
+
:date => Date.parse(values[0]),
|
44
|
+
:description => values[1],
|
45
|
+
:serial => values[2],
|
46
|
+
:total => convert_money_to_integer(total)
|
47
|
+
}
|
48
|
+
transactions << Transaction.new(transaccion_info)
|
49
|
+
end
|
50
|
+
transactions
|
51
|
+
end
|
52
|
+
|
53
|
+
def new_session
|
54
|
+
agent = Mechanize.new
|
55
|
+
agent.user_agent_alias=BROWSER
|
56
|
+
agent.get(URL)
|
57
|
+
form = agent.page.form(LOGIN_FORM_NAME)
|
58
|
+
|
59
|
+
form["frm"]="frm"
|
60
|
+
form["frm:canal"]="110"
|
61
|
+
form["frm:clave"]= self.password
|
62
|
+
form["frm:clave_aux"]=""
|
63
|
+
form["frm:dvCliente"] = self.user[-1] #digito verificador rut
|
64
|
+
form["frm:grupo"] = ""
|
65
|
+
form["frm:j_idt12"] ="Ingresar"
|
66
|
+
# Rut only numbers without verification
|
67
|
+
form["frm:rutCliente"]= self.user[0..-2].gsub(/[\--.]/,'')
|
68
|
+
form["frm:rut_aux"] = ""
|
69
|
+
form["frm:servicioInicial"]="SuperCartola"
|
70
|
+
form["frm:touch"] = "#{(Time.now.to_f*1000).to_i}"
|
71
|
+
form["frm:transaccion"] = ""
|
72
|
+
form.submit
|
73
|
+
agent
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
def clean_string(html_object)
|
78
|
+
# We have to remove the special   character, which is not a \s+
|
79
|
+
nbsp = Nokogiri::HTML(" ").text
|
80
|
+
# This is the text of the html element
|
81
|
+
text_of_html_el = html_object.children.text
|
82
|
+
text_of_html_el.strip.gsub(nbsp,'').gsub(/\n/,'')
|
83
|
+
end
|
84
|
+
|
85
|
+
def convert_money_to_integer(money)
|
86
|
+
int = money.gsub(/[\$.]/,'').gsub(/\s+/,'')
|
87
|
+
int.to_i
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class BCIMobiBank < Bank
|
4
|
+
attr_accessor :user, :password
|
5
|
+
attr_reader :session
|
6
|
+
|
7
|
+
URL = "https://bci.mobi"
|
8
|
+
LOGIN_FORM_NAME = "loginform"
|
9
|
+
BROWSER = "Mac FireFox"
|
10
|
+
START_URL = "https://bci.mobi/supercartola.do"
|
11
|
+
|
12
|
+
def initialize(account = {})
|
13
|
+
@user = account[:user]
|
14
|
+
@password = account[:password]
|
15
|
+
@session = new_session
|
16
|
+
end
|
17
|
+
|
18
|
+
def url
|
19
|
+
URL
|
20
|
+
end
|
21
|
+
|
22
|
+
def balance
|
23
|
+
# We make sure we are on the first page
|
24
|
+
session.get(START_URL)
|
25
|
+
# The balance is in the 5 table, second tr, second td inside a div
|
26
|
+
string_balance = session.page.root.css("table")[4].css("tr")[1].css("td")[1].children.text
|
27
|
+
# Remove de $ simbol and the dots
|
28
|
+
string_balance.gsub!(/[\$-.]/,'')
|
29
|
+
# Return Integer
|
30
|
+
string_balance.to_i
|
31
|
+
end
|
32
|
+
|
33
|
+
def get_transactions
|
34
|
+
transactions = []
|
35
|
+
# We go to the transactions page
|
36
|
+
session.get(START_URL)
|
37
|
+
# Go to transaction pages
|
38
|
+
# 4 link, the first that reads "Más"
|
39
|
+
session.page.links[3].click
|
40
|
+
# Tables that hold the transactions, 3 tables per page
|
41
|
+
tables = session.page.root.css("table")[5].css("tr")[1].css("td").css("table")
|
42
|
+
tables.each do |table|
|
43
|
+
h = {
|
44
|
+
:date => table.css("tr")[0].css("td")[1].text,
|
45
|
+
:description => table.css("tr")[1].css("td")[1].text,
|
46
|
+
:serial => table.css("tr")[2].css("td")[1].text,
|
47
|
+
:total => table.css("tr")[3].css("td")[1].text
|
48
|
+
}
|
49
|
+
transactions << h
|
50
|
+
end
|
51
|
+
transactions
|
52
|
+
end
|
53
|
+
|
54
|
+
def new_session
|
55
|
+
agent = Mechanize.new
|
56
|
+
agent.user_agent_alias=BROWSER
|
57
|
+
agent.get(URL)
|
58
|
+
form = agent.page.form(LOGIN_FORM_NAME)
|
59
|
+
form.rut = self.user
|
60
|
+
form.clave = self.password
|
61
|
+
form.canal = "901"
|
62
|
+
form.menu_opcion="targetSupercartola"
|
63
|
+
form.submit
|
64
|
+
agent
|
65
|
+
if agent.page.root.css("table").first.css("h1").text.eql?("Autentificación Inválida")
|
66
|
+
false
|
67
|
+
elsif agent.page.root.css("table").first.css("h1").text.eql?("Clave bloqueada")
|
68
|
+
false
|
69
|
+
elsif agent.page.root.css("table").first.css("h1").text.eql?("Error desconocido.")
|
70
|
+
false
|
71
|
+
else
|
72
|
+
agent
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
class CHILEEMPRESASBank < Bank
|
2
|
+
attr_accessor :user, :password, :account_number, :company_rut
|
3
|
+
attr_reader :session
|
4
|
+
|
5
|
+
HOST = "www.empresas.bancochile.cl"
|
6
|
+
URL = "https://#{HOST}/cgi-bin/navega?pagina=enlinea/login_fus"
|
7
|
+
LOGIN_FORM_NAME = "theform"
|
8
|
+
BROWSER = "Mac FireFox"
|
9
|
+
START_URL = "https://www.empresas.bancochile.cl/CCOLSaldoMovimientosWEB/selectorCuentas.do?accion=initSelectorCuentas&moneda=CTD&cuenta="
|
10
|
+
|
11
|
+
def initialize(account = {})
|
12
|
+
@company_rut = account[:company_rut]
|
13
|
+
@user = account[:user]
|
14
|
+
@password = account[:password]
|
15
|
+
@account_number = account[:number]
|
16
|
+
@session = new_session
|
17
|
+
end
|
18
|
+
|
19
|
+
def url
|
20
|
+
URL
|
21
|
+
end
|
22
|
+
|
23
|
+
def balance
|
24
|
+
# We make sure we are on the first page
|
25
|
+
session.get("#{START_URL}#{self.account_number}")
|
26
|
+
# The value is inside a div#saldos in the second td
|
27
|
+
string_balance = clean_string(session.page.root.css("#estaCuen").css(".detalleSaldosMov").css("td").last)
|
28
|
+
# The above result has an ":" character that we need to remove
|
29
|
+
string_balance.gsub!(/:/,'')
|
30
|
+
# Remove de $ simbol and the dots
|
31
|
+
convert_money_to_integer(string_balance)
|
32
|
+
end
|
33
|
+
|
34
|
+
def transactions
|
35
|
+
transactions = []
|
36
|
+
total = 0
|
37
|
+
movements = get_transactions_json
|
38
|
+
movements.each do |mov|
|
39
|
+
|
40
|
+
if mov[4].empty? # Out money
|
41
|
+
total = convert_money_to_integer(mov[5])
|
42
|
+
else
|
43
|
+
total = convert_money_to_integer(mov[4]) * -1
|
44
|
+
end
|
45
|
+
|
46
|
+
transaccion_info = {
|
47
|
+
:date => Date.parse(mov[0]),
|
48
|
+
:description => mov[1],
|
49
|
+
:total => total
|
50
|
+
}
|
51
|
+
transactions << Transaction.new(transaccion_info)
|
52
|
+
end
|
53
|
+
transactions
|
54
|
+
end
|
55
|
+
|
56
|
+
def new_session
|
57
|
+
agent = Mechanize.new
|
58
|
+
agent.user_agent_alias=BROWSER
|
59
|
+
agent.get(URL)
|
60
|
+
form = agent.page.form(LOGIN_FORM_NAME)
|
61
|
+
|
62
|
+
form["rut_emp"] = self.company_rut[0..-2].gsub(/[\--.]/,'')
|
63
|
+
form["dv_emp"] = self.company_rut[-1]
|
64
|
+
form["rut_apo"] = self.user[0..-2].gsub(/[\--.]/,'')
|
65
|
+
form["dv_apo"] = self.user[-1]
|
66
|
+
form["pin"] = self.password
|
67
|
+
|
68
|
+
form.submit
|
69
|
+
agent
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
def clean_string(html_object)
|
74
|
+
# We have to remove the special   character, which is not a \s+
|
75
|
+
nbsp = Nokogiri::HTML(" ").text
|
76
|
+
# This is the text of the html element
|
77
|
+
text_of_html_el = html_object.children.text
|
78
|
+
text_of_html_el.strip.gsub(nbsp,'').gsub(/\n/,'')
|
79
|
+
end
|
80
|
+
|
81
|
+
def convert_money_to_integer(money)
|
82
|
+
int = money.gsub(/[\$.]/,'').gsub(/\s+/,'')
|
83
|
+
int.to_i
|
84
|
+
end
|
85
|
+
|
86
|
+
def get_transactions_json
|
87
|
+
self.balance
|
88
|
+
cookie = session.cookies.join("; ")
|
89
|
+
path = "/CCOLSaldoMovimientosWEB/generadorMovimientosJSON.do"
|
90
|
+
params = {
|
91
|
+
"sEcho"=> "4",
|
92
|
+
"iColumns" => "7",
|
93
|
+
"iDisplayStart" => "0",
|
94
|
+
"iDisplayLength" => "100"
|
95
|
+
}
|
96
|
+
http = Net::HTTP.new(HOST, 443)
|
97
|
+
http.use_ssl = true
|
98
|
+
request = Net::HTTP::Post.new(path)
|
99
|
+
request.set_form_data(params)
|
100
|
+
request.add_field("X-Requested-With", "XMLHttpRequest")
|
101
|
+
request.add_field('Cookie', cookie)
|
102
|
+
response = http.request(request)
|
103
|
+
json = JSON.parse(response.body)
|
104
|
+
clean_json(json["aaData"])
|
105
|
+
end
|
106
|
+
|
107
|
+
def clean_json(json)
|
108
|
+
json.each do |arr|
|
109
|
+
[4, 5, 6].each do |el|
|
110
|
+
arr[el] = Nokogiri::HTML::parse(arr[el]).text # remove <p> tags
|
111
|
+
end
|
112
|
+
end
|
113
|
+
json
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Transaction
|
2
|
+
attr_reader :total, :date, :description, :type
|
3
|
+
|
4
|
+
def initialize(hash)
|
5
|
+
@total = hash[:total]
|
6
|
+
@date = hash[:date]
|
7
|
+
@description = hash[:description]
|
8
|
+
end
|
9
|
+
|
10
|
+
def income?
|
11
|
+
total > 0
|
12
|
+
end
|
13
|
+
|
14
|
+
def outcome?
|
15
|
+
total < 0
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
data/lib/cartolify.rb
ADDED
data/test/helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
require 'turn'
|
4
|
+
begin
|
5
|
+
Bundler.setup(:default, :development)
|
6
|
+
rescue Bundler::BundlerError => e
|
7
|
+
$stderr.puts e.message
|
8
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
9
|
+
exit e.status_code
|
10
|
+
end
|
11
|
+
require 'test/unit'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib', 'lib/cartolify',
|
15
|
+
'lib/cartolify/banks'))
|
16
|
+
require 'cartolify'
|
17
|
+
|
18
|
+
class Test::Unit::TestCase
|
19
|
+
|
20
|
+
def bank_account
|
21
|
+
account = {
|
22
|
+
:user => ENV['bank_user'],
|
23
|
+
:password => ENV['bank_password'],
|
24
|
+
:number => ENV['bank_account_number']
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
data/test/test_bank.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestBank < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@bank = Bank.new("BCI", bank_account)
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_new_bank_should_return_an_specfic_bank_Class_Instance
|
10
|
+
assert_equal(BCIBank, @bank.branch.class)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_url_should_return_and_https_url
|
14
|
+
assert_equal("https", URI(@bank.url).scheme)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_should_get_a_session
|
18
|
+
session = @bank.session
|
19
|
+
assert(session)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_balance_should_return_a_number
|
23
|
+
balance = @bank.balance
|
24
|
+
assert_equal(Fixnum, balance.class)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_transactions_should_return_an_array
|
28
|
+
transactions = @bank.transactions
|
29
|
+
assert_equal(Array, transactions.class)
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'helper'
|
3
|
+
require 'cartolify/banks/bci_bank'
|
4
|
+
|
5
|
+
class TestBCIBank < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@bank = BCIBank.new( bank_account )
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_user_should_not_be_nil
|
12
|
+
assert_not_nil(@bank.user)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_password_should_not_be_nil
|
16
|
+
assert_not_nil(@bank.password)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Comment for now because it may block the account
|
20
|
+
# def test_wrong_login_should_be_false
|
21
|
+
# bank = BCIBank.new({:user => "13.834.853-9", :password => "mdoad"})
|
22
|
+
# session = bank.login
|
23
|
+
# assert(!session, "Should be False")
|
24
|
+
# end
|
25
|
+
|
26
|
+
def test_should_get_a_session
|
27
|
+
session = @bank.session
|
28
|
+
assert(session)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_balance_should_return_an_Fixnum
|
32
|
+
balance = @bank.balance
|
33
|
+
assert_equal(Fixnum, balance.class)
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cartolify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Patricio Bruna
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: mechanize
|
16
|
+
requirement: &70181271682280 !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: *70181271682280
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: nokogiri
|
27
|
+
requirement: &70181271715480 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70181271715480
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: json
|
38
|
+
requirement: &70181271712300 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70181271712300
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rdoc
|
49
|
+
requirement: &70181271710800 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.12'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70181271710800
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: bundler
|
60
|
+
requirement: &70181271709360 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ~>
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 1.0.0
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70181271709360
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: jeweler
|
71
|
+
requirement: &70181271723740 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ~>
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 1.8.3
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70181271723740
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: turn
|
82
|
+
requirement: &70181271720060 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *70181271720060
|
91
|
+
description: This is the Engine for my Budget System
|
92
|
+
email: pbruna@gmail.com
|
93
|
+
executables: []
|
94
|
+
extensions: []
|
95
|
+
extra_rdoc_files:
|
96
|
+
- LICENSE.txt
|
97
|
+
- README.rdoc
|
98
|
+
files:
|
99
|
+
- .document
|
100
|
+
- Gemfile
|
101
|
+
- Gemfile.lock
|
102
|
+
- LICENSE.txt
|
103
|
+
- README.rdoc
|
104
|
+
- Rakefile
|
105
|
+
- VERSION
|
106
|
+
- lib/cartolify.rb
|
107
|
+
- lib/cartolify/account.rb
|
108
|
+
- lib/cartolify/bank.rb
|
109
|
+
- lib/cartolify/banks/bci_bank.rb
|
110
|
+
- lib/cartolify/banks/bci_mobi_bank.rb
|
111
|
+
- lib/cartolify/banks/chileempresas_bank.rb
|
112
|
+
- lib/cartolify/transaction.rb
|
113
|
+
- test/helper.rb
|
114
|
+
- test/test_bank.rb
|
115
|
+
- test/test_bci_bank.rb
|
116
|
+
- test/test_cartolify.rb
|
117
|
+
homepage: http://github.com/pbruna/cartolify
|
118
|
+
licenses:
|
119
|
+
- MIT
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
none: false
|
126
|
+
requirements:
|
127
|
+
- - ! '>='
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
segments:
|
131
|
+
- 0
|
132
|
+
hash: -1886146149934546780
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
|
+
none: false
|
135
|
+
requirements:
|
136
|
+
- - ! '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
requirements: []
|
140
|
+
rubyforge_project:
|
141
|
+
rubygems_version: 1.8.10
|
142
|
+
signing_key:
|
143
|
+
specification_version: 3
|
144
|
+
summary: Lib for getting info of Chilean Banks
|
145
|
+
test_files: []
|