Class: VimEpidemic::Plugin

Inherits:
Object
  • Object
show all
Defined in:
lib/vim-epidemic/plugin.rb

Instance Method Summary collapse

Constructor Details

#initialize(config, *args, block) ⇒ Plugin

Returns a new instance of Plugin.



6
7
8
9
10
11
12
# File 'lib/vim-epidemic/plugin.rb', line 6

def initialize config, *args, block
  @config = config
  options = args.last.kind_of?(Hash) ? args.pop : {}
  @source = args.shift
  @type = args.shift || options[:type]
  @block = block
end

Instance Method Details

#installObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/vim-epidemic/plugin.rb', line 18

def install
  FileUtils.mkdir_p @config.bundle_dir
  if File.exists? dir
    Dir.chdir dir
    `git pull`
  else
    Dir.chdir @config.bundle_dir
    `git clone #{complete_source} #{name}`
    Dir.chdir dir if $? == 0
  end
  call_block if $? == 0
  $? == 0
end

#installed?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/vim-epidemic/plugin.rb', line 36

def installed?
  File.exists? dir
end

#match?(*args) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/vim-epidemic/plugin.rb', line 14

def match? *args
  complete_source(args.first) == complete_source
end

#to_sObject



32
33
34
# File 'lib/vim-epidemic/plugin.rb', line 32

def to_s
  "#{name} (#{complete_source})"
end