This repository has been archived by the owner on May 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
lazy_developer_tasks.rake
95 lines (64 loc) · 2.04 KB
/
lazy_developer_tasks.rake
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
95
VERSION="1.1.8"
namespace :lazy do
desc "Shows the version of Lazy Developer this app uses"
task :version do
puts "LazyDeveloper v#{VERSION}"
end
end
namespace :db do
# Override the original Rake task to clone the test database too
task :migrate do
unless RAILS_ENV == "production"
puts "Preparing Test database"
Rake::Task['db:test:clone'].invoke
end
end
# Override the original rake task when running a specific migration up
namespace :migrate do
task :up => :environment do
unless RAILS_ENV == "production"
puts "Preparing Test database"
Rake::Task['db:test:clone'].invoke
end
end
task :down => :environment do
unless RAILS_ENV == "production"
puts "Preparing Test database"
Rake::Task['db:test:clone'].invoke
end
end
end
# Drops and remigrates tables in case you hurt your database somehow
# Borrowed from http://errtheblog.com/post/3
desc "Drops and re-migrates tables"
task :remigrate => :environment do
# don't run in production mode
return unless %w(development test).include? RAILS_ENV
ActiveRecord::Base.connection.tables.each { |t| ActiveRecord::Base.connection.drop_table t }
Rake::Task['db:migrate'].invoke
end
end
namespace :rails do
namespace :install do
desc "installs your favorite plugins by looking in your home folder for a file called .plugins"
task :plugins do
File.open("#{ENV['HOME']}/.plugins", "r") do |f|
while (line = f.gets)
begin
sh "ruby script/plugin install #{line}"
rescue
puts "Couldn't install #{line}"
end
end
end
end
end #install
end # rails
namespace :clear do
desc "Clean up all temp, logs, and docs"
task :all do
Rake::Task['tmp:clear'].invoke
Rake::Task['log:clear'].invoke
Rake::Task['doc:clobber_rails'].invoke
end
end