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.
18 19 20 21 22 23 24 |
# File 'lib/vundle_cli/uninstaller.rb', line 18 def initialize(, bundle) @options = @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.
16 17 18 |
# File 'lib/vundle_cli/uninstaller.rb', line 16 def bundle @bundle end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/vundle_cli/uninstaller.rb', line 8 def @options end |
#settings_dir ⇒ Object (readonly)
Returns the value of attribute settings_dir.
12 13 14 |
# File 'lib/vundle_cli/uninstaller.rb', line 12 def settings_dir @settings_dir end |
#vimdir ⇒ Object (readonly)
Returns the value of attribute vimdir.
10 11 12 |
# File 'lib/vundle_cli/uninstaller.rb', line 10 def vimdir @vimdir end |
#vimrc ⇒ Object (readonly)
Returns the value of attribute vimrc.
14 15 16 |
# File 'lib/vundle_cli/uninstaller.rb', line 14 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.
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 60 |
# File 'lib/vundle_cli/uninstaller.rb', line 29 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.downcase.include?(bundle_name.downcase) 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 |