forked from mutewinter/Showbot
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathRakefile
More file actions
116 lines (99 loc) · 3 KB
/
Copy pathRakefile
File metadata and controls
116 lines (99 loc) · 3 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
require 'rake/testtask'
require 'bundler/setup'
namespace :test do
Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = FileList['test/*test.rb']
t.verbose = true
end
end
namespace :spec do
begin
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:unit) do |spec|
spec.pattern = 'test/unit/**{,/*/**}/*_spec.rb'
spec.verbose = false
end
RSpec::Core::RakeTask.new(:acceptance) do |spec|
spec.pattern = 'test/acceptance/**{,/*/**}/*_spec.rb'
spec.verbose = false
end
rescue LoadError
# no rspec available
end
end
# -----------------------
# Database
# -----------------------
MIGRATIONS_PATH = File.join(File.dirname(__FILE__), 'db', 'migrate')
namespace :db do
desc 'Run pending database migrations'
task :migrate => :environment do
conn = ActiveRecord::Base.connection
ctx = ActiveRecord::MigrationContext.new(MIGRATIONS_PATH, ActiveRecord::Base.connection_pool.schema_migration)
ctx.migrate
puts "Migrations complete. Current version: #{ctx.current_version}"
end
desc 'Roll back the last migration'
task :rollback => :environment do
conn = ActiveRecord::Base.connection
ctx = ActiveRecord::MigrationContext.new(MIGRATIONS_PATH, ActiveRecord::Base.connection_pool.schema_migration)
ctx.rollback
puts "Rolled back to version: #{ctx.current_version}"
end
desc 'Show current migration version'
task :version => :environment do
conn = ActiveRecord::Base.connection
ctx = ActiveRecord::MigrationContext.new(MIGRATIONS_PATH, ActiveRecord::Base.connection_pool.schema_migration)
puts "Current version: #{ctx.current_version}"
end
desc 'Seed the database with some fake title suggestions'
task :seed => :environment do
5.times do |n|
Suggestion.create(
title: "Test #{Time.now.to_i} #{n}",
show: 'b2w',
user: 'derp'
)
end
end
end
task :environment do
require File.join(File.dirname(__FILE__), 'environment')
end
namespace :backup do
task :run do
`backup perform -t showbot_backup -c './config/backup.rb'`
end
end
namespace :foreman do
desc 'Export foreman upstart config for Showbot'
task :export do
sh 'sudo foreman export upstart /etc/init -a showbot -p 5000 -u deploy'
end
end
# -----------------------
# SASS
# -----------------------
namespace :sass do
desc 'Watches and compiles sass to proper directory'
task :watch => :environment do
sh 'sass --watch --load-path sass sass/showbot.scss public/css/showbot.css'
end
end
# -----------------------
# Api Key Tasks
# -----------------------
namespace :api_key do
desc 'Generates an Api Key for Showbot and prints it out to the console.'
task :generate => :environment do
print "Application Name (required): "
app_name = STDIN::gets.chomp.strip
key = ApiKey.create(app_name: app_name)
if app_name
puts "Here's the Api key for #{app_name}: #{key.value}"
else
puts "App name required to make a key. We gotta keep track of this stuff."
end
end
end