-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
68 lines (54 loc) · 1.71 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
require 'bundler/setup'
require 'rake/testtask'
$: << File.expand_path(File.join(File.dirname(__FILE__), 'lib'))
namespace :bundler do
task :setup do
require 'rubygems'
require 'bundler/setup'
end
end
task :environment, [:env] => 'bundler:setup' do |cmd, args|
ENV['RACK_ENV'] = args[:env] || 'development'
require 'headspace'
end
desc 'Minify client-side application assets'
task :build do
sh %{cd public/js && node vendor/r.js -o app-build.js}
end
namespace :db do
desc 'Run database migrations'
task :migrate, :env do |cmd, args|
env = args[:env] || 'development'
Rake::Task[:environment].invoke(env)
require 'sequel/extensions/migration'
Sequel::Migrator.apply(Headspace::DB, File.join(File.dirname(__FILE__), 'migrations'))
end
desc 'Setup database triggers'
task :setup, :env do |cmd, args|
env = args[:env] || 'development'
Rake::Task[:environment].invoke(env)
Headspace::DB.pgt_created_at(:users, :created_at)
Headspace::DB.pgt_updated_at(:users, :updated_at)
Headspace::DB.pgt_created_at(:links, :created_at)
Headspace::DB.pgt_updated_at(:links, :updated_at)
Headspace::DB.pgt_created_at(:starred_links, :created_at)
end
desc 'Drop all tables'
task :nuke, :env do |cmd, args|
env = args[:env] || 'development'
Rake::Task[:environment].invoke(env)
Headspace::DB.tables.each do |table|
Headspace::DB << "DROP TABLE #{table} CASCADE"
end
end
desc 'Reset the database'
task :reset, :env do |cmd, args|
env = args[:env] || 'development'
Rake::Task['db:nuke'].invoke(env)
Rake::Task['db:migrate'].invoke(env)
Rake::Task['db:setup'].invoke(env)
end
end
Rake::TestTask.new do |t|
t.pattern = 'test/*_test.rb'
end