mirror of
https://github.com/hakanensari/frankfurter.git
synced 2024-10-29 23:32:35 +01:00
Add environment task
This commit is contained in:
parent
dc03a5838f
commit
e80a0e00a3
2
Rakefile
2
Rakefile
@ -1,5 +1,3 @@
|
||||
require_relative 'config/environment'
|
||||
|
||||
Dir.glob('lib/tasks/*.rake').each { |r| import r }
|
||||
|
||||
task :default => [:test]
|
||||
|
@ -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')
|
||||
|
3
lib/tasks/environment.rake
Normal file
3
lib/tasks/environment.rake
Normal file
@ -0,0 +1,3 @@
|
||||
task :environment do
|
||||
require './config/environment'
|
||||
end
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user