From 46fad8cc1567bdf7c8dbc323b8234aeb8d47ad1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20M=C3=BCller?= Date: Sat, 19 Dec 2009 16:12:23 +0800 Subject: [PATCH] Better Rake file (I think :) Instead we copy the snippets we link them in. So each change while development can used directly without rake again. --- Rakefile | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/Rakefile b/Rakefile index 22ce2180a..4408445b2 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,55 @@ #require 'fileutils' #include FileUtils +require 'rake' + +# The install task was stolen from RyanB +# http://github.com/ryanb/dotfiles + +desc "install the snippets into user's vim directory @home" +task :install => ["snippets_dir:find"] do + replace_all = false + Dir['*'].each do |file| + next if %w[Rakefile].include? file + + if File.exist?(File.join(@snippets_dir, "#{file}")) + if replace_all + replace_file(file) + else + print "overwrite #{File.join(@snippets_dir, file)}? [ynaq] " + case $stdin.gets.chomp + when 'a' + replace_all = true + replace_file(file) + when 'y' + replace_file(file) + when 'q' + exit + else + puts File.join(@snippets_dir, "#{file}") + end + end + else + link_file(file) + end + end +end + +def replace_file(file) + link_file(file) +end + +def link_file(file) + puts "linking #{path_to(file)}" + ln_s File.join(FileUtils.pwd,file), path_to(file), :force => true +end + +def path_to(file) + File.join(@snippets_dir, "#{file}") +end + namespace :snippets_dir do + desc "Sets @snippets_dir dependent on which OS You run" task :find do @snippets_dir = File.join(ENV['VIMFILES'] || ENV['HOME'] || ENV['USERPROFILE'], RUBY_PLATFORM =~ /mswin32/ ? "vimfiles" : ".vim", "snippets") end @@ -20,3 +68,9 @@ task :deploy_local => ["snippets_dir:purge"] do end cp "support_functions.vim", @snippets_dir, :verbose => true end + +desc "Alias for purge" +task :purge => ["snippets_dir:purge"] + +desc "Alias for default task run easy 'rake'" +task :default => :install