Class: Vim::Jar::Config
- Inherits:
-
Object
- Object
- Vim::Jar::Config
- Includes:
- Singleton
- Defined in:
- lib/vim-jar/config.rb
Constant Summary collapse
- PATHOGEN_URL =
"http://www.vim.org/scripts/download_script.php?src_id=12116"
Instance Method Summary collapse
- #autoload_home ⇒ Object
- #bundle_home ⇒ Object
- #check ⇒ Object
- #check_vim_pathes! ⇒ Object
- #create_bundle_home ⇒ Object
- #gitconfig_file_path ⇒ Object
- #gitmodules_file_path ⇒ Object
- #has_bundle_home? ⇒ Boolean
- #has_pathgen? ⇒ Boolean
- #init_git_repo ⇒ Object
- #install_pathogen ⇒ Object
- #pathogen_path ⇒ Object
- #pathogen_vim_path(version = "1.2") ⇒ Object
- #setup_pathogen ⇒ Object
- #under_git? ⇒ Boolean
- #user_home ⇒ Object
- #vim_home ⇒ Object
- #vim_jar_lib ⇒ Object
- #vim_jar_root ⇒ Object
- #vimrc_path ⇒ Object
- #yaml_path ⇒ Object
Instance Method Details
#autoload_home ⇒ Object
46 47 48 |
# File 'lib/vim-jar/config.rb', line 46 def autoload_home Pathname.new(vim_home.join("autoload")) end |
#bundle_home ⇒ Object
41 42 43 |
# File 'lib/vim-jar/config.rb', line 41 def bundle_home Pathname.new(vim_home.join("bundle")) end |
#check ⇒ Object
71 72 73 74 75 76 |
# File 'lib/vim-jar/config.rb', line 71 def check check_vim_pathes! self.init_git_repo unless under_git? self.setup_pathogen unless has_pathgen? self.create_bundle_home unless has_bundle_home? end |
#check_vim_pathes! ⇒ Object
78 79 80 81 82 83 |
# File 'lib/vim-jar/config.rb', line 78 def check_vim_pathes! %w[vim_home vimrc_path].each do |method_name| path = self.send(method_name) raise InitError.new("#{path} doesn't exist") unless File.exist?(path) end end |
#create_bundle_home ⇒ Object
98 99 100 101 |
# File 'lib/vim-jar/config.rb', line 98 def create_bundle_home FileUtils.mkdir_p(bundle_home) STDOUT.puts "create folder for pathogen in #{bundle_home}" end |
#gitconfig_file_path ⇒ Object
37 38 39 |
# File 'lib/vim-jar/config.rb', line 37 def gitconfig_file_path vim_home.join(".git",'config') end |
#gitmodules_file_path ⇒ Object
33 34 35 |
# File 'lib/vim-jar/config.rb', line 33 def gitmodules_file_path vim_home.join(".gitmodules") end |
#has_bundle_home? ⇒ Boolean
66 67 68 |
# File 'lib/vim-jar/config.rb', line 66 def has_bundle_home? File.exist?(self.bundle_home) end |
#has_pathgen? ⇒ Boolean
62 63 64 |
# File 'lib/vim-jar/config.rb', line 62 def has_pathgen? File.exist?(self.pathogen_path) end |
#init_git_repo ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/vim-jar/config.rb', line 85 def init_git_repo Dir.chdir(self.vim_home) do = <<-EOF your .vim folder is not a git repository. we'll init git repository for you. You can make use of git submodule to manage your plugins. Futher more you can push your git repository to www.github.com. EOF STDOUT.puts system("git init") end end |
#install_pathogen ⇒ Object
116 117 118 119 |
# File 'lib/vim-jar/config.rb', line 116 def install_pathogen FileUtils.mkdir_p(autoload_home) if !File.exist?(autoload_home) FileUtils.cp pathogen_vim_path, pathogen_path end |
#pathogen_path ⇒ Object
50 51 52 |
# File 'lib/vim-jar/config.rb', line 50 def pathogen_path Pathname.new(vim_home.join("autoload",'pathogen.vim')) end |
#pathogen_vim_path(version = "1.2") ⇒ Object
58 59 60 |
# File 'lib/vim-jar/config.rb', line 58 def pathogen_vim_path(version="1.2") vim_jar_lib.join("vim-jar","pathogen","pathogen_v#{version}.vim") end |
#setup_pathogen ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/vim-jar/config.rb', line 103 def setup_pathogen self.install_pathogen STDOUT.puts <<-EOF Pathogen is installed into #{self.pathogen_path}. NOTICE: you need copy line below into #{self.vimrc_path}. call pathogen#runtime_append_all_bundles() EOF end |
#under_git? ⇒ Boolean
29 30 31 |
# File 'lib/vim-jar/config.rb', line 29 def under_git? @under_git ||= File.exist?(vim_home.join(".git")) end |
#user_home ⇒ Object
17 18 19 |
# File 'lib/vim-jar/config.rb', line 17 def user_home Pathname.new(ENV['VIM_JAR_USER_HOME'] || ::Gem.user_home) end |
#vim_home ⇒ Object
21 22 23 |
# File 'lib/vim-jar/config.rb', line 21 def vim_home Pathname.new(user_home.join(".vim")) end |
#vim_jar_lib ⇒ Object
13 14 15 |
# File 'lib/vim-jar/config.rb', line 13 def vim_jar_lib Pathname.new(vim_jar_root.join("lib")) end |
#vim_jar_root ⇒ Object
9 10 11 |
# File 'lib/vim-jar/config.rb', line 9 def vim_jar_root Pathname.new(File.("../../",File.dirname(__FILE__))) end |
#vimrc_path ⇒ Object
25 26 27 |
# File 'lib/vim-jar/config.rb', line 25 def vimrc_path user_home.join(".vimrc") end |
#yaml_path ⇒ Object
54 55 56 |
# File 'lib/vim-jar/config.rb', line 54 def yaml_path @yaml_path ||= File.("./plugins.yml",File.dirname(__FILE__)) end |