forked from rikai/Showbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
106 lines (91 loc) · 2.46 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
95
96
97
98
99
100
101
102
103
104
105
106
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
# -----------------------
namespace :db do
desc 'Auto-migrate the database (destroys data)'
task :migrate => :environment do
puts "This will destroy all data in the _#{ENV['RACK_ENV']}_ database, continue? (yN)"
if STDIN::gets.strip.downcase == 'y'
DataMapper.auto_migrate!
else
puts "Okay, exiting."
end
end
desc 'Auto-upgrade the database (preserves data)'
task :upgrade => :environment do
DataMapper.auto_upgrade!
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 -r ./sass/bourbon/lib/bourbon.rb 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