forked from soulnafein/vim-on-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
59 lines (48 loc) · 1.32 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
require File.dirname(__FILE__) + '/helpers'
include FileUtils
HOME_FOLDER = File.expand_path("~")
INSTALLATION_PATH = join_path(HOME_FOLDER, ".vim_on_rails")
BACKUP_PATH = join_path(INSTALLATION_PATH, "backup")
FILES_TO_BACKUP = %w( .vim .vimrc .gvimrc )
task :install => [:backup, :install_configuration] do
install_vundle
install_plugins
end
task :backup do
backup_current_environment
end
task :install_configuration do
install_config_files
end
task :uninstall do
restore_backup_environment
delete_installation_folder
end
def backup_current_environment
mkdir_p(BACKUP_PATH)
FILES_TO_BACKUP.each do |file|
mv_if_exists(join_path(HOME_FOLDER, file), BACKUP_PATH)
end
end
def restore_backup_environment
rm_r(join_path(HOME_FOLDER, '.vim'))
FILES_TO_BACKUP.each do |file|
mv_if_exists(join_path(BACKUP_PATH, file), HOME_FOLDER)
end
end
def delete_installation_folder
rm_r(INSTALLATION_PATH)
end
def install_config_files
cp(%w( .vimrc ), HOME_FOLDER)
end
def install_vundle
vundle_installation_folder = join_path(HOME_FOLDER, '.vim/bundle/vundle')
vundle_git_repo = "http://github.com/gmarik/vundle.git"
sh "git clone #{vundle_git_repo} #{vundle_installation_folder}"
mkdir_p(join_path(HOME_FOLDER, '.vim/swaps'))
end
def install_plugins
cd INSTALLATION_PATH
sh 'vim +"BundleInstall" +"quit"'
end