-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathRakefile
37 lines (33 loc) · 882 Bytes
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
def rm(f)
@runtime ||= Time.now.to_i
return if !File.exist?(f)
mv f, "#{ENV['HOME']}/.Trash/#{File.basename(f)}_#{@runtime}"
end
desc 'initialize task'
task :initialize => [:symlink_dir, :symlink_file, :erb]
task :symlink_dir do
%w[vim/ftplugin vim/after].each do |src|
dest = "~/.vim/#{src[/[^\/]+$/]}"
src, dest = File.expand_path(src), File.expand_path(dest)
rm dest
ln_s src, dest
end
end
task :symlink_file do
FileList['_*'].each do |src|
next if /\.erb$/ =~ src
dest = "#{ENV['HOME']}/.#{src[1..-1]}"
src, dest = File.expand_path(src), File.expand_path(dest)
# src: _vimrc, dest: ~/.vimrc
rm dest
ln_s src, dest
end
end
desc 'erb'
task :erb do
FileList['_*.erb'].each do |src|
dest = File.expand_path('~') + "/.#{src.match(/^_(.*?)\.erb$/)[1]}"
rm dest
sh "erb -r ./secret.rb #{src} > #{dest}"
end
end