Class: VimPathogenPluginManager::Manager

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

Instance Method Summary collapse

Constructor Details

#initializeManager

Returns a new instance of Manager.



10
11
12
13
14
# File 'lib/vim_pathogen_plugin_manager.rb', line 10

def initialize
  # getting Home dir + vim budles dir
  @dir = Dir.open Dir.home + "/.vim/bundle/"
  @bundle_list = Dir.home + "/.vim/bundle.list"
end

Instance Method Details

#parse_optionsObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/vim_pathogen_plugin_manager.rb', line 16

def parse_options
  @options = {}

  @opts = OptionParser.new

  @opts.banner = "Usage: plugin_manager.rb [options]"

  @opts.on("-u", "--update", "Update all Vim plugins") do |u|
    @options[:action] = "u"
  end

  @opts.on("-i", "--install", "Install Vim plugins from list [bundle.list]") do |i|
    @options[:action] = "i"
  end

  @opts.on("-r", "--remove", "Remove Vim plugins not on the list [bundle.list]") do |r|
    @options[:action] = "r"
  end

  @opts.on("-p", "--path [path_to_file]", "Path to [bundle.list]") do |p|
    @options[:path] = p
  end

  @opts.on_tail("-h", "--help", "Show this message") do
    puts @opts
    exit
  end

  @opts.on_tail("--version", "Show version") do
    puts VimPathogenPluginManager::VERSION
    exit
  end

  @opts.on_tail("--usage", "Show usage example") do
    puts "Example usage (install plugins)".colorize(:yellow) + " vim_pathogen_plugin_manager -i -p /home/user/custom_bundle.list".colorize(:light_blue)
    exit
  end

  begin
    @opts.parse!(ARGV)
  rescue OptionParser::InvalidOption => e
    puts e
    puts @opts
  end
end

#runObject



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/vim_pathogen_plugin_manager.rb', line 62

def run
  valid_option = true

  if @options[:path] then
    @bundle_list = @options[:path]
  end

  case @options[:action]
    when "u"
      update
    when "i"
      install
    when "r"
      remove
    else
      puts @opts
      valid_option = false
  end

  if valid_option then
    print "done :)\n".colorize(:light_magenta)
  end
end