Class: VundleCli::Uninstaller
- Inherits:
-
Object
- Object
- VundleCli::Uninstaller
- Defined in:
- lib/vundle_cli/uninstaller.rb
Instance Attribute Summary collapse
-
#bundle ⇒ Object
readonly
Returns the value of attribute bundle.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#settings_dir ⇒ Object
readonly
Returns the value of attribute settings_dir.
-
#vimdir ⇒ Object
readonly
Returns the value of attribute vimdir.
-
#vimrc ⇒ Object
readonly
Returns the value of attribute vimrc.
Instance Method Summary collapse
-
#initialize(options, bundle) ⇒ Uninstaller
constructor
A new instance of Uninstaller.
-
#rm ⇒ Object
1) Remove the line ‘Bundle bundle` from .vimrc.
Constructor Details
#initialize(options, bundle) ⇒ Uninstaller
Returns a new instance of Uninstaller.
17 18 19 20 21 22 23 |
# File 'lib/vundle_cli/uninstaller.rb', line 17 def initialize(, bundle) = @vimdir = Helpers.file_validate(.vimdir, true) @settings_dir = Helpers.file_validate(.settings, true) @vimrc = Helpers.file_validate(.vimrc) @bundle = bundle end |
Instance Attribute Details
#bundle ⇒ Object (readonly)
Returns the value of attribute bundle.
15 16 17 |
# File 'lib/vundle_cli/uninstaller.rb', line 15 def bundle @bundle end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/vundle_cli/uninstaller.rb', line 7 def end |
#settings_dir ⇒ Object (readonly)
Returns the value of attribute settings_dir.
11 12 13 |
# File 'lib/vundle_cli/uninstaller.rb', line 11 def settings_dir @settings_dir end |
#vimdir ⇒ Object (readonly)
Returns the value of attribute vimdir.
9 10 11 |
# File 'lib/vundle_cli/uninstaller.rb', line 9 def vimdir @vimdir end |
#vimrc ⇒ Object (readonly)
Returns the value of attribute vimrc.
13 14 15 |
# File 'lib/vundle_cli/uninstaller.rb', line 13 def vimrc @vimrc end |
Instance Method Details
#rm ⇒ Object
1) Remove the line ‘Bundle bundle` from .vimrc. 2) Look for a file in the settings directory (provided by option –settings)
with name that includes the bundle name. Then ask if the user wants to remove it.
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 |
# File 'lib/vundle_cli/uninstaller.rb', line 28 def rm tmp = Tempfile.new("vimrc_tmp") open(@vimrc, 'r').each { |l| if l.chomp =~ /Bundle .*#{Regexp.quote(@bundle)}.*/ puts "Found bundle #{@bundle}, removing it from #{@vimrc}..." else tmp << l end } tmp.close FileUtils.mv(tmp.path, @vimrc) puts "Searching for setting file..." # Get the bundle's main name. # (the provided @bundle usually looks like baopham/trailertrash.vim, # so we trim it down to get "trailertrash" only). bundle_name = @bundle if @bundle.include?("/") bundle_name = @bundle.split("/")[1].sub(/\.vim/, '') end Dir.foreach(@settings_dir) do |fname| next unless fname.include? bundle_name puts "Found #{@settings_dir}/#{fname} setting file. Remove it? (yes/no) " input = STDIN.gets.chomp if input == 'yes' File.delete("#{@settings_dir}/#{fname}") puts "File deleted." end end end |