Class: Vim::Jar::Config
- Inherits:
-
Object
- Object
- Vim::Jar::Config
- Includes:
- Singleton
- Defined in:
- lib/vim-jar/config.rb
Instance Method Summary collapse
- #autoload_home ⇒ Object
- #bundle_file_path ⇒ Object
- #bundle_home ⇒ Object
- #bundle_template_file_path ⇒ Object
- #check ⇒ Object
- #check_vim_pathes! ⇒ Object
- #create_bundle_home ⇒ Object
- #gitconfig_file_path ⇒ Object
- #gitmodules_file_path ⇒ Object
- #init_bundle_file ⇒ Object
- #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
Instance Method Details
#autoload_home ⇒ Object
44 45 46 |
# File 'lib/vim-jar/config.rb', line 44 def autoload_home Pathname.new(vim_home.join("autoload")) end |
#bundle_file_path ⇒ Object
56 57 58 |
# File 'lib/vim-jar/config.rb', line 56 def bundle_file_path vim_home.join("BundleFile") end |
#bundle_home ⇒ Object
39 40 41 |
# File 'lib/vim-jar/config.rb', line 39 def bundle_home Pathname.new(vim_home.join("bundle")) end |
#bundle_template_file_path ⇒ Object
60 61 62 |
# File 'lib/vim-jar/config.rb', line 60 def bundle_template_file_path vim_jar_lib.join("templates", "BundleFile") end |
#check ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/vim-jar/config.rb', line 64 def check check_vim_pathes! self.init_git_repo unless under_git? self.setup_pathogen unless File.exist?(self.pathogen_path) self.create_bundle_home unless File.exist?(self.bundle_home) self.init_bundle_file unless File.exists?(self.bundle_file_path) end |
#check_vim_pathes! ⇒ Object
72 73 74 75 76 77 |
# File 'lib/vim-jar/config.rb', line 72 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
92 93 94 95 |
# File 'lib/vim-jar/config.rb', line 92 def create_bundle_home FileUtils.mkdir_p(bundle_home) STDOUT.puts "create folder for pathogen in #{bundle_home}" end |
#gitconfig_file_path ⇒ Object
35 36 37 |
# File 'lib/vim-jar/config.rb', line 35 def gitconfig_file_path vim_home.join(".git",'config') end |
#gitmodules_file_path ⇒ Object
31 32 33 |
# File 'lib/vim-jar/config.rb', line 31 def gitmodules_file_path vim_home.join(".gitmodules") end |
#init_bundle_file ⇒ Object
115 116 117 118 119 120 121 122 123 |
# File 'lib/vim-jar/config.rb', line 115 def init_bundle_file FileUtils.cp bundle_template_file_path, bundle_file_path STDOUT.puts <<-EOF Writing new BundleFile to #{self.bundle_file_path}. You can add more plugins by modify this file EOF end |
#init_git_repo ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/vim-jar/config.rb', line 79 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
110 111 112 113 |
# File 'lib/vim-jar/config.rb', line 110 def install_pathogen FileUtils.mkdir_p(autoload_home) if !File.exist?(autoload_home) FileUtils.cp pathogen_vim_path, pathogen_path end |
#pathogen_path ⇒ Object
48 49 50 |
# File 'lib/vim-jar/config.rb', line 48 def pathogen_path Pathname.new(vim_home.join("autoload",'pathogen.vim')) end |
#pathogen_vim_path(version = "1.2") ⇒ Object
52 53 54 |
# File 'lib/vim-jar/config.rb', line 52 def pathogen_vim_path(version="1.2") vim_jar_lib.join("vim-jar","pathogen","pathogen_v#{version}.vim") end |
#setup_pathogen ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/vim-jar/config.rb', line 97 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
27 28 29 |
# File 'lib/vim-jar/config.rb', line 27 def under_git? @under_git ||= File.exist?(vim_home.join(".git")) end |
#user_home ⇒ Object
15 16 17 |
# File 'lib/vim-jar/config.rb', line 15 def user_home Pathname.new(ENV['VIM_JAR_USER_HOME'] || ::Gem.user_home) end |
#vim_home ⇒ Object
19 20 21 |
# File 'lib/vim-jar/config.rb', line 19 def vim_home Pathname.new(user_home.join(".vim")) end |
#vim_jar_lib ⇒ Object
11 12 13 |
# File 'lib/vim-jar/config.rb', line 11 def vim_jar_lib Pathname.new(vim_jar_root.join("lib")) end |
#vim_jar_root ⇒ Object
7 8 9 |
# File 'lib/vim-jar/config.rb', line 7 def vim_jar_root Pathname.new(File.("../../",File.dirname(__FILE__))) end |
#vimrc_path ⇒ Object
23 24 25 |
# File 'lib/vim-jar/config.rb', line 23 def vimrc_path user_home.join(".vimrc") end |