Browse code

Update to rakefile to allow working on a single post at a time (and saving regeneration time)

Ryan Daigle authored on 23/01/2010 at 20:47:43
Showing 2 changed files
... ...
@@ -1,3 +1,4 @@
1 1
 site
2
-*/.sass-cache
3
-.DS_Store
4 2
\ No newline at end of file
3
+.sass-cache
4
+test
5
+source/_stash
... ...
@@ -4,6 +4,8 @@ site_url  = "http://yoursite.com"   # deployed site url for sitemap.xml generato
4 4
 port      = "4000"     # preview project port eg. http://localhost:4000
5 5
 site      = "site"     # compiled site directory
6 6
 source    = "source" # source file directory
7
+stash     = "_stash"
8
+posts     = "_posts"
7 9
 
8 10
 ## -- Rsync Deploy config -- ##
9 11
 ssh_user      = "user@host.com"    # for rsync deployment
... ...
@@ -47,6 +49,21 @@ task :post, :filename do |t, args|
47 47
   end
48 48
 end
49 49
 
50
+# usage rake isolate[my-post]
51
+desc "Move all other posts than the one currently being worked on to a temporary stash location (stash) so regenerating the site happens much quicker."
52
+task :isolate, :filename do |t, args|
53
+  stash_dir = "#{source}/#{stash}"
54
+  FileUtils.mkdir(stash_dir) unless File.exist?(stash_dir)
55
+  Dir.glob("#{source}/#{posts}/*.*") do |post|
56
+    FileUtils.mv post, stash_dir unless post.include?(args.filename)
57
+  end
58
+end
59
+
60
+desc "Move all stashed posts back into the posts directory, ready for site generation."
61
+task :integrate do
62
+  FileUtils.mv Dir.glob("#{source}/#{stash}/*.*"), "#{source}/#{posts}/"
63
+end
64
+
50 65
 desc "list tasks"
51 66
 task :list do
52 67
   puts "Tasks: #{(Rake::Task.tasks - [Rake::Task[:list]]).to_sentence}"
... ...
@@ -109,13 +126,13 @@ task :watch do
109 109
 end
110 110
 
111 111
 desc "generate and deploy website via rsync"
112
-multitask :deploy_rsync => [:default, :clean_debug] do
112
+multitask :deploy_rsync => [:integrate, :default, :clean_debug] do
113 113
   puts ">>> Deploying website to #{site_url} <<<"
114 114
   ok_failed system("rsync -avz --delete #{site}/ #{ssh_user}:#{document_root}")
115 115
 end
116 116
 
117 117
 desc "generate and deploy website to github user pages"
118
-multitask :deploy_github => [:default, :clean_debug] do
118
+multitask :deploy_github => [:integrate, :default, :clean_debug] do
119 119
   puts ">>> Deploying #{deploy_branch} branch to Github Pages <<<"
120 120
   require 'git'
121 121
   repo = Git.open('.')