all repos — h3rald @ cc50c9eee3f6eb9771d49973b6bbe0db9ef6a6ec

The sources of https://h3rald.com

Created convenience rake tasks.
h3rald h3rald@h3rald.com
Sat, 08 Aug 2009 12:05:15 +0200
commit

cc50c9eee3f6eb9771d49973b6bbe0db9ef6a6ec

parent

602db5c59a42a8497d6c2563a2223cfd9b003cc2

3 files changed, 47 insertions(+), 28 deletions(-)

jump to
M RakefileRakefile

@@ -1,4 +1,4 @@

Dir['tasks/**/*.rake'].sort.each { |rakefile| load rakefile; puts rakefile } -task :default => [:copy_files] do +task :default => ["site:update"] do end
D tasks/copy_files.rake

@@ -1,27 +0,0 @@

-require 'rubygems' -require 'extlib' -require 'pathname' -require 'fileutils' - - - -task :copy_files do - pwd = Pathname.new Dir.pwd - file_dirs = [Pathname.new(pwd/'files/images'), - Pathname.new(pwd/'files/js'), - Pathname.new(pwd/'files/css')] - file_dirs.each do |d| - d.find do |src| - if src.file? then - rel_path = src.relative_path_from(pwd/'files').to_s - dst = Pathname.new(pwd/"output/#{rel_path}") - if !dst.exist? || dst.exist? && !FileUtils.cmp(dst.to_s, src.to_s) then - dst.parent.mkpath - FileUtils.cp src.to_s, dst.to_s - puts "Copied '#{src}'." - end - end - end - end - -end
A tasks/site.rake

@@ -0,0 +1,46 @@

+require 'rubygems' +require 'extlib' +require 'pathname' +require 'fileutils' + + +namespace :site do + + task :clear_output do + output = Pathname.new(Dir.pwd)/'output' + puts "Deleting all files in output dir..." + output.rmtree + end + + task :update => [:copy_files] do + system "nanoc co" + end + + task :run => [:copy_files] do + system "nanoc aco" + end + + task :rebuild => [:clear_output, :copy_files, :update] do + end + + task :copy_files do + pwd = Pathname.new Dir.pwd + file_dirs = [Pathname.new(pwd/'files/images'), + Pathname.new(pwd/'files/js'), + Pathname.new(pwd/'files/css')] + file_dirs.each do |d| + d.find do |src| + if src.file? then + rel_path = src.relative_path_from(pwd/'files').to_s + dst = Pathname.new(pwd/"output/#{rel_path}") + if !dst.exist? || dst.exist? && !FileUtils.cmp(dst.to_s, src.to_s) then + dst.parent.mkpath + FileUtils.cp src.to_s, dst.to_s + puts "Copied '#{src}'." + end + end + end + end + end + +end