Class: VundleCli::Installer

Inherits:
Object
  • Object
show all
Defined in:
lib/vundle_cli/installer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, plugin = nil) ⇒ Installer

Returns a new instance of Installer.



10
11
12
13
14
15
16
17
# File 'lib/vundle_cli/installer.rb', line 10

def initialize(options, plugin = nil)
  @options = options
  @vimdir = file_validate(options.vimdir, true)
  @vimrc = file_validate(options.vimrc)
  unless plugin.nil?
    @plugin = plugin
  end
end

Instance Attribute Details

#forceObject (readonly)

Returns the value of attribute force.



8
9
10
# File 'lib/vundle_cli/installer.rb', line 8

def force
  @force
end

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/vundle_cli/installer.rb', line 8

def options
  @options
end

#pluginObject (readonly)

Returns the value of attribute plugin.



8
9
10
# File 'lib/vundle_cli/installer.rb', line 8

def plugin
  @plugin
end

#settings_dirObject (readonly)

Returns the value of attribute settings_dir.



8
9
10
# File 'lib/vundle_cli/installer.rb', line 8

def settings_dir
  @settings_dir
end

#vimdirObject (readonly)

Returns the value of attribute vimdir.



8
9
10
# File 'lib/vundle_cli/installer.rb', line 8

def vimdir
  @vimdir
end

#vimrcObject (readonly)

Returns the value of attribute vimrc.



8
9
10
# File 'lib/vundle_cli/installer.rb', line 8

def vimrc
  @vimrc
end

Instance Method Details

#installObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/vundle_cli/installer.rb', line 20

def install

    say "Writing plugin in #{@vimrc}..."
    tmp = Tempfile.new("vimrc_tmp")
    open(@vimrc, 'r').each { |l| 
      if l.chomp =~ /vundle#begin/
        l << "\nPlugin '#{@plugin}'"
      end
      tmp << l
    }
    tmp.close
    FileUtils.mv(tmp.path, @vimrc)
    say "Waiting for plugin installing complete..."
    system "vim +PluginInstall +qall"
end