Add environment task

This commit is contained in:
hakanensari 2014-03-14 12:49:16 +00:00
parent dc03a5838f
commit e80a0e00a3
5 changed files with 13 additions and 10 deletions

View File

@ -1,5 +1,3 @@
require_relative 'config/environment'
Dir.glob('lib/tasks/*.rake').each { |r| import r }
task :default => [:test]

View File

@ -1,6 +1,6 @@
namespace :db do
desc 'Run database migrations'
task :migrate do
task migrate: :environment do
Sequel.extension(:migration)
db = Sequel::DATABASES.first
dir = App.root.join('db/migrate')

View File

@ -0,0 +1,3 @@
task :environment do
require './config/environment'
end

View File

@ -1,16 +1,18 @@
require 'currency'
require 'fixer'
namespace :rates do
task setup: :environment do
require 'currency'
require 'fixer'
end
desc 'Reload all rates'
task :reload do
Currency.delete
task reload: :setup do
Currency.dataset.delete
data = Fixer::Feed.new(:historical)
Currency.multi_insert(data.to_a)
end
desc 'Update rates'
task :update do
task update: :setup do
Fixer::Feed.new.each do |hsh|
Currency.find_or_create(hsh)
end

View File

@ -1,6 +1,6 @@
require 'rake/testtask'
Rake::TestTask.new do |t|
Rake::TestTask.new(test: :environment) do |t|
t.libs.push('lib')
t.test_files = FileList['spec/*_spec.rb']
end