blob: d36a84d9096a3cfc93adc3db39543af866fc3b67 (
plain)
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
|
require 'active_support'
def ok_failed(condition)
if (condition)
puts "OK"
else
puts "FAILED"
end
end
port = "4000"
site = "site"
desc "list tasks"
task :default do
puts "Tasks: #{(Rake::Task.tasks - [Rake::Task[:default]]).to_sentence}"
puts "(type rake -T for more detail)\n\n"
end
desc "remove files in output directory"
task :clean do
puts "Removing output..."
Dir["#{site}/*"].each { |f| rm_rf(f) }
end
desc "generate website in output directory"
task :generate => :clean do
puts "Generating website..."
system "compass"
system "jekyll"
Dir["#{site}/stylesheets/*.sass"].each { |f| rm_rf(f) }
system "mv #{site}/atom.html #{site}/atom.xml"
end
desc "generate and deploy website"
task :deploy => :generate do
print "Deploying website..."
ok_failed system("rsync -avz --delete #{site}/ user@host.com:~/document_root/")
end
desc "start up an instance of serve on the output files"
task :start_serve => :stop_serve do
cd "#{site}" do
print "Starting serve..."
ok_failed system("serve #{port} > /dev/null 2>&1 &")
end
end
desc "stop all instances of serve"
task :stop_serve do
pid = `ps auxw | awk '/bin\\/serve\\ #{port}/ { print $2 }'`.strip
if pid.empty?
puts "Serve is not running"
else
print "Stoping serve..."
ok_failed system("kill -9 #{pid}")
end
end
desc "preview the site in a web browser"
multitask :preview => [:generate, :start_serve] do
system "open http://localhost:#{port}"
end
|