Module: Vim::Jar::Installer::Git
Instance Method Summary collapse
- #config ⇒ Object
- #install_to(source, output_path) ⇒ Object
- #remove_from_cache(name) ⇒ Object
- #remove_ref_from_git_config(name) ⇒ Object
- #remove_ref_from_gitmodules(name) ⇒ Object
- #uninstall_for(name) ⇒ Object
Instance Method Details
#config ⇒ Object
61 62 63 |
# File 'lib/vim-jar/installer/git.rb', line 61 def config ::Vim::Jar::Config.instance end |
#install_to(source, output_path) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/vim-jar/installer/git.rb', line 7 def install_to(source, output_path) Dir.chdir(config.vim_home) do system("git submodule add #{source} #{Pathname.new(output_path).relative_path_from(config.vim_home)}") system("git submodule init") end end |
#remove_from_cache(name) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/vim-jar/installer/git.rb', line 20 def remove_from_cache(name) Dir.chdir(config.vim_home) do system("git rm -rf --cached bundle/#{name}") end Dir.chdir(config.vim_home) do system("rm -rf bundle/#{name}") end end |
#remove_ref_from_git_config(name) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/vim-jar/installer/git.rb', line 45 def remove_ref_from_git_config(name) #TODO bundle name is different to submodule name f = File.new(config.gitconfig_file_path) lines = f.lines.to_a lines.delete_if do |x| x =~ /bundle\/#{name}/ || x =~ /#{name}\.git$/ end f.close File.open(config.gitconfig_file_path, "w") do |ff| lines.each do |l| ff.puts l end end end |
#remove_ref_from_gitmodules(name) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/vim-jar/installer/git.rb', line 29 def remove_ref_from_gitmodules(name) #TODO bundle name is different to submodule name f = File.new(config.gitmodules_file_path) lines = f.lines.to_a lines.delete_if do |x| x =~ /bundle\/#{name}/ || x =~ /#{name}\.git$/ end f.close File.open(config.gitmodules_file_path, "w") do |ff| lines.each do |l| ff.puts l end end end |
#uninstall_for(name) ⇒ Object
14 15 16 17 18 |
# File 'lib/vim-jar/installer/git.rb', line 14 def uninstall_for(name) remove_ref_from_gitmodules(name) remove_ref_from_git_config(name) remove_from_cache(name) end |