Skip to content

Instantly share code, notes, and snippets.

@youpy
Created October 15, 2008 11:24
Show Gist options
  • Save youpy/16893 to your computer and use it in GitHub Desktop.
Save youpy/16893 to your computer and use it in GitHub Desktop.
require 'rake'
include FileUtils::Verbose
SRC = FileList.new
Dir.glob(File.join('config', '**', '*'), File::FNM_DOTMATCH).each do |path|
if File.file?(path) && path !~ /\.svn/
SRC.add(path)
end
end
DST = SRC.gsub(/^config/, '')
SRC.zip(DST) do |src, dst|
desc "Deploy #{dst}"
file dst => src do
cp src, dst
end
end
desc "Add file (rake add FILE=filename)"
task :add do
dst = ENV['FILE']
raise "Not a file" unless File.file?(dst)
src = File.join('config', dst)
mkdir_p File.dirname(src)
cp dst, src
end
desc "Remove file (rake remove FILE=filename)"
task :remove do
SRC.zip(DST) do |src, dst|
if ENV['FILE'] == dst
rm src
break
end
end
end
desc "List files under management"
task :list do
puts DST.join("\n")
end
task :default => DST
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment