Sha256: 215ef44b0ccd93644d560696dbb1f05fc5e2c0c4430cf40e619fbbd0c71f9c7a

Contents?: true

Size: 1.51 KB

Versions: 1

Compression:

Stored size: 1.51 KB

Contents

require 'neobundle/vimscript'

module NeoBundle
  class Runner
    attr_reader :script
    
    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
    
    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
    
    def list
      @script.exec('NeoBundleList', $stdout)
    end
    
    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
    
    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
neobundle-0.2.0 lib/neobundle/runner.rb