-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
executable file
·73 lines (61 loc) · 1.91 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
#change these values if you deploy with rsync
ssh_user = "[email protected]" # for rsync deployment
remote_root = "~/document_root/" # for rsync deployment
source = "src" #source directory (needed to auto-rebuild site on changes)
desc "Runs preview"
task :preview do
system "compass watch . &"
system "staticmatic preview ."
end
desc "Builds the site"
task :build => 'styles:clear' do
puts "*** Building the site ***"
system "staticmatic build ."
end
desc "Clears and generates new styles, builds and deploys"
task :deploy => [:build, :push] do
puts "*** Deploying the site ***"
end
desc "push"
task :push do
system("rsync -avz --delete site/ #{ssh_user}:#{remote_root}")
end
namespace :styles do
desc "Clears the styles"
task :clear do
puts "*** Clearing styles ***"
system "rm -Rfv site/stylesheets/*"
end
desc "Generates new styles"
task :generate do
puts "*** Generating styles ***"
system "compass compile"
end
end
def rebuild_site(relative)
puts "\n\n>>> Change Detected to: #{relative} <<<"
if (relative.include? ".sass") || (relative.include? ".scss")
IO.popen('rake styles:generate'){|io| print(io.readpartial(512)) until io.eof?}
puts '>>> Update Styles Complete <<<'
else
IO.popen('rake build'){|io| print(io.readpartial(512)) until io.eof?}
puts '>>> Update Site Complete <<<'
end
end
def rebuild_style(relative)
puts "\n\n>>> Change Detected to: #{relative} <<<"
IO.popen('rake styles:generate'){|io| print(io.readpartial(512)) until io.eof?}
puts '>>> Update Complete <<<'
end
desc "Watch the site and regenerate when it changes"
task :watch do
require 'fssm'
puts ">>> Watching for Changes <<<"
FSSM.monitor do
path "#{File.dirname(__FILE__)}/#{source}" do
update {|base, relative| rebuild_site(relative)}
delete {|base, relative| rebuild_site(relative)}
create {|base, relative| rebuild_site(relative)}
end
end
end