Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
73 lines (55 sloc) 1.47 KB
require 'lib/saffron'
@countries = {'us' => 'US', 'canada' => 'Canada'}
@banks = {'ing' => 'ING', 'hsbc' => 'HSBC', 'amex' => 'AMEX', 'capital_one' => 'CapitalOne'}
def update(country, bank)
require "lib/banks/#{country}/#{bank}"
country_module = Kernel.const_get(@countries[country])
bank_module = country_module.const_get(@banks[bank])
parser_class = bank_module.const_get('Parser')
downloader_class = bank_module.const_get('Downloader')
csv_path = ENV["#{country.upcase}_#{bank.upcase}_CSV_PATH"]
parser = parser_class.new(ENV['ING_CSV_PATH'])
script = UpdateScript.new(downloader_class.start, parser)
script.update!
end
task :default => ['canada:hsbc', 'canada:ing', 'us:amex', 'us:ing', 'us:capital_one']
namespace :canada do
desc "Update HSBC"
task :hsbc do
update 'canada', 'hsbc'
end
desc "Update ING"
task :ing do
update 'canada', 'ing'
end
end
namespace :us do
desc "Update AMEX"
task :amex do
update 'us', 'amex'
end
desc "Update ING"
task :ing do
update 'us', 'ing'
end
desc "Update Capital One"
task :capital_one do
update 'us', 'capital_one'
end
end
namespace :db do
desc "Create the database"
task :create do
ActiveRecord::Migration.class_eval do
create_table :transactions do |t|
t.string :account
t.string :category
t.string :with
t.string :raw_with
t.decimal :amount
t.string :currency
t.date :occurred_on
end
end
end
end