stash_dir = "_stash" # directory to stash posts for speedy generation
full_stash_dir = "#{source_dir}/#{stash_dir}" # full path for stash dir
+stash_root_dir = "_stash_root" # directory to stash pages (in /source/)+full_stash_root_dir = "#{source_dir}/#{stash_root_dir}" # full path for stash_root dir+root_stashes = ['mac', 'windows', 'others', 'privacy', 'rawhtml', 'search_test'] # directories to be stashed in /source/posts_dir = "_posts" # directory for blog files
# usage rake isolate[my-post]
desc "Move all other posts than the one currently being worked on to a temporary stash location (stash) so regenerating the site happens much more quickly."
task :isolate, :filename do |t, args|
FileUtils.mkdir(full_stash_dir) unless File.exist?(full_stash_dir)
Dir.glob("#{source_dir}/#{posts_dir}/*") do |post|
FileUtils.mv post, full_stash_dir unless post.end_with?(args.filename)
end
+ FileUtils.mkdir(full_stash_root_dir) unless File.exist?(full_stash_root_dir)+ if defined? root_stashes == nil+ if root_stashes.class == String+ FileUtils.mv "#{source_dir}/#{root_stashes}", full_stash_root_dir+ elsif root_stashes.class == Array+ for d in root_stashes do+ FileUtils.mv "#{source_dir}/#{d}", full_stash_root_dir+ end+ end+ end system "touch .isolated"
end
最後にintegrateの方でも元に戻す様に追加。
Rakefile
123456789
# usage rake isolate[my-post]
desc "Move all stashed posts back into the posts directory, ready for site generation."
task :integrate do
FileUtils.mv Dir.glob("#{full_stash_dir}/*"), "#{source_dir}/#{posts_dir}/"
+ FileUtils.mv Dir.glob("#{full_stash_root_dir}/*"), "#{source_dir}/" system "rm -f .isolated"
system "touch .integrated"
end