forked from puppetlabs-toy-chest/razor-server
-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathRakefile
94 lines (76 loc) · 2.28 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
require 'rake'
require 'pathname'
load './acceptance/tasks/acceptance.rake'
RAKE_ROOT = File.expand_path(File.dirname(__FILE__))
begin
require 'torquebox-rake-support'
rescue LoadError
STDERR.puts "Unable to load 'torquebox-rake-support'. Some rake tasks may be unavailable without this library."
end
task :default do
system("rake -T")
end
namespace :bundler do
task :setup do
require 'bundler/setup'
end
end
task :environment, [:env] => 'bundler:setup' do |cmd, args|
ENV["RACK_ENV"] = args[:env] || "development"
require_relative "./lib/razor/initialize"
end
namespace :db do
desc "Run database migrations"
task :migrate, :env do |cmd, args|
env = args[:env] || "development"
Rake::Task['environment'].invoke(env)
sh "./bin/razor-admin -e #{env} migrate-database"
end
desc "Rollback the database"
task :rollback, :env do |cmd, args|
env = args[:env] || "development"
Rake::Task['environment'].invoke(env)
require 'sequel/extensions/migration'
version = (row = Razor.database[:schema_info].first) ? row[:version] : nil
Sequel::Migrator.apply(Razor.database, "db/migrate", version - 1)
end
desc "Nuke the database (drop all tables)"
task :nuke, :env do |cmd, args|
env = args[:env] || "development"
Rake::Task['environment'].invoke(env)
sh "./bin/razor-admin -e #{env} reset-database"
end
desc "Reset the database"
task :reset, [:env] => [:nuke, :migrate]
end
if defined?(RSpec::Core::RakeTask)
namespace :spec do
require 'rspec/core'
require 'rspec/core/rake_task'
task :reset_tests do
Rake::Task['db:reset'].invoke("test")
end
desc "Run all specs"
RSpec::Core::RakeTask.new(:all => :reset_tests) do |t|
t.pattern = 'spec/**/*_spec.rb'
end
end
end
desc "Open a preloaded irb session"
task :console do
$: << File::expand_path(File::join(File::dirname(__FILE__), "lib"))
require 'irb'
require 'razor/initialize'
require 'razor'
puts "Model classes from Razor::Data have been included in the toplevel"
include Razor::Data
ARGV.clear
IRB.start
end
begin
spec = Gem::Specification.find_by_name 'gettext-setup'
load "#{spec.gem_dir}/lib/tasks/gettext.rake"
GettextSetup.initialize(File.absolute_path('locales', File.dirname(__FILE__)))
rescue LoadError
# ignore
end