Class: Vim::Jar::Config

Inherits:
Object
  • Object
show all
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

Instance Method Details

#autoload_homeObject



46
47
48
# File 'lib/vim-jar/config.rb', line 46

def autoload_home 
  Pathname.new(vim_home.join("autoload"))
end

#bundle_homeObject



41
42
43
# File 'lib/vim-jar/config.rb', line 41

def bundle_home 
  Pathname.new(vim_home.join("bundle"))
end

#checkObject



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_homeObject



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_pathObject



37
38
39
# File 'lib/vim-jar/config.rb', line 37

def gitconfig_file_path
  vim_home.join(".git",'config')
end

#gitmodules_file_pathObject



33
34
35
# File 'lib/vim-jar/config.rb', line 33

def gitmodules_file_path
  vim_home.join(".gitmodules")
end

#has_bundle_home?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


62
63
64
# File 'lib/vim-jar/config.rb', line 62

def has_pathgen?
  File.exist?(self.pathogen_path)
end

#init_git_repoObject



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 
    message = <<-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 message
    system("git init")
  end
end

#install_pathogenObject



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_pathObject



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_pathogenObject



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

Returns:

  • (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_homeObject



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_homeObject



21
22
23
# File 'lib/vim-jar/config.rb', line 21

def vim_home 
  Pathname.new(user_home.join(".vim"))
end

#vim_jar_libObject



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_rootObject



9
10
11
# File 'lib/vim-jar/config.rb', line 9

def vim_jar_root 
  Pathname.new(File.expand_path("../../",File.dirname(__FILE__)))
end

#vimrc_pathObject



25
26
27
# File 'lib/vim-jar/config.rb', line 25

def vimrc_path
  user_home.join(".vimrc")
end

#yaml_pathObject



54
55
56
# File 'lib/vim-jar/config.rb', line 54

def yaml_path
  @yaml_path ||= File.expand_path("./plugins.yml",File.dirname(__FILE__))
end