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.



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

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::NeoBundleError, '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
20
# File 'lib/neobundle/runner.rb', line 7

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

Instance Method Details

#cleanObject



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

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



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

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



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

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