Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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.
  • Loading branch information...
commit 46fad8cc1567bdf7c8dbc323b8234aeb8d47ad1c 1 parent 1e49df0
@zzeroo zzeroo authored rafaelfranca committed
Showing with 54 additions and 0 deletions.
  1. +54 −0 Rakefile
View
54 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
Please sign in to comment.
Something went wrong with that request. Please try again.