-
Notifications
You must be signed in to change notification settings - Fork 5
/
Rakefile
68 lines (62 loc) · 1.76 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
#!/usr/bin/env rake
require 'rspec/core/rake_task'
# Skip integration specs by default
RSpec::Core::RakeTask.new('spec') do |t|
t.rspec_opts = '--tag ~integration'
end
RSpec::Core::RakeTask.new('spec:integration') do |t|
t.rspec_opts = '--tag integration'
end
desc "Initial setup"
task :setup do
`bundle`
`bundle exec vendorer install`
puts "Successfully setup. Running 'rackup'... Visit http://localhost:9292/"
`bundle exec rackup`
end
desc <<-DESC
Deploy application to heroku.
account=[name] if multiple heroku accounts
app=[name] if a different app name than directory
DESC
task :deploy do
system "git init 1>/dev/null"
remotes = `git remote`.chomp.split("\n")
if remotes.include? 'heroku'
`git push heroku master`
else
command = ['heroku', 'apps:create']
app_name = ENV['app'].dup if ENV['app']
app_name ||= File.basename(File.expand_path("..", __FILE__))
app_name.gsub!('_', '-')
command << app_name
command << ['-s', 'cedar']
command << ['--account', ENV['account']] if ENV['account']
command.flatten!
puts "Executing: #{command * ' '}\n\n"
output = IO.popen(command << {:err => [:child, :out]}) do |io|
io.read
end
unless $?.success?
puts "Something went wrong.\n"
case output
when /No account specified/
puts "Ambiguous heroku accounts, try 'rake deploy account=youraccount'"
when /Name is already taken/
puts "App name already taken, try 'rake deploy app=another-app-name'"
else
puts output
end
else
puts output
end
end
end
desc "Remove tmp files"
task :clean do
`rm -rf tmp/*`
`find . -name '*.orig' | xargs rm -f`
`find . -name '*.rej' | xargs rm -f`
`find . -name '*~' | xargs rm -f`
end
task :default => :spec