This repository has been archived by the owner on Jan 11, 2019. It is now read-only.
forked from carlhuda/janus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
72 lines (60 loc) · 1.63 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
60
61
62
63
64
65
66
67
68
69
70
71
72
module Janus
# Errors
JanusError = Class.new Exception
BlockNotGivenError = Class.new JanusError
end
# Return the root path
#
# @return [String] The absolute path to Janus repository
def root_path
@root_path ||= File.expand_path(File.dirname(__FILE__))
end
def expand(file)
File.expand_path(file)
end
# Install a plugin
#
# @param [String] The group the plugin belongs to
# @param [String] The plugin name
# @param [&block] The installation block
def install_vim_plugin(group, name, &block)
raise Janus::BlockNotGivenError unless block_given?
# Create a namespace for the plugin
namespace(name) do
task :verify_plugin do
unless Dir["#{root_path}/#{group}/#{name}/**"].any?
abort "The submodule #{group}/#{name} is not ready, please run 'git submodule update --init'"
end
end
# Define the plugin installation task
desc "Install #{name} plugin."
task :install do
puts
puts "*" * 40
puts "*#{"Installing #{name}".center(38)}*"
puts "*" * 40
puts
yield
end
task :install => :verify_plugin
end
# Hook the plugin's install task to the global install task
task :install => "#{name}:install"
end
# Load all plugin installation tasks
Dir["#{root_path}/janus-*/tasks/**.rake"].each { |f| import f }
task expand("~/.vimrc") => "vimrc" do
sh "ln -s ~/.vim/vimrc ~/.vimrc"
end
task expand("~/.gvimrc") => "gvimrc" do
sh "ln -s ~/.vim/gvimrc ~/.gvimrc"
end
task :update do
sh "git pull"
sh "git submodule init"
sh "git submodule update"
end
task :install => :update do
# Dummy task.
end
task :default => [:install, expand("~/.vimrc"), expand("~/.gvimrc")]