Class: NeoBundle::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/neobundle/runner.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}, script = nil) ⇒ Runner

Returns a new instance of Runner.



21
22
23
24
25
26
27
28
# File 'lib/neobundle/runner.rb', line 21

def initialize(config={}, script=nil)
  @script = script || Vimscript.new(self.class.default_config.merge(config))
  begin
    self.script.exec('NeoBundleList')
  rescue NeoBundle::VimscriptError
    raise NeoBundle::NeoBundleNotFoundError, 'NeoBundle not found!'
  end
end

Instance Attribute Details

#scriptObject (readonly)

Returns the value of attribute script.



5
6
7
# File 'lib/neobundle/runner.rb', line 5

def script
  @script
end

Class Method Details

.default_config(platform = RUBY_PLATFORM) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/neobundle/runner.rb', line 7

def self.default_config(platform = RUBY_PLATFORM)
  config = {
    vim: ENV['NEOBUNDLE_CMD_VIM'] || 'vim',
    vimrc: ENV['NEOBUNDLE_CMD_VIMRC'],
  }
  case platform
  when /darwin/,/linux/ then
    config[:vimrc] ||= File.join(ENV['HOME'], '.vimrc')
  when /mswin(?!ce)|mingw|cygwin|bccwin/ then
    config[:vimrc] ||= File.join(ENV['HOME'], '_vimrc')
  end
  config
end

Instance Method Details

#cleanObject



42
43
44
45
46
47
48
# File 'lib/neobundle/runner.rb', line 42

def clean
  dir = @script.exec('echo neobundle#get_neobundle_dir()').strip
  before = Dir['%s/*' % dir]
  @script.exec('NeoBundleClean!', $stdout)
  after = Dir['%s/*' % dir]
  raise NeoBundle::OperationAlreadyCompletedError, 'Already cleaned!' if before == after
end

#installObject



34
35
36
37
38
39
40
# File 'lib/neobundle/runner.rb', line 34

def install
  dir = @script.exec('echo neobundle#get_neobundle_dir()').strip
  before = Dir['%s/*' % dir]
  @script.exec('NeoBundleInstall', $stdout)
  after = Dir['%s/*' % dir]
  raise NeoBundle::OperationAlreadyCompletedError, 'Already installed!' if before == after
end

#listObject



30
31
32
# File 'lib/neobundle/runner.rb', line 30

def list
  @script.exec('NeoBundleList', $stdout)
end