Class: VPM::ManifestParser

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeManifestParser

Returns a new instance of ManifestParser.



7
8
9
# File 'lib/vpm/manifest_parser.rb', line 7

def initialize
  @plugins = {}
end

Class Method Details

.parse(content) ⇒ Object



3
4
5
# File 'lib/vpm/manifest_parser.rb', line 3

def self.parse(content)
  self.new.parse(content)
end

Instance Method Details

#options_to_args(options) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/vpm/manifest_parser.rb', line 23

def options_to_args(options)
  args = []

  if options[:git]
    args += ["--git", options[:git]]
    args += ["--tag", options[:tag]] if options[:tag]
  end

  args
end

#parse(content) ⇒ Object



11
12
13
14
# File 'lib/vpm/manifest_parser.rb', line 11

def parse(content)
  instance_eval(content)
  plugins
end

#plugin(name, options = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/vpm/manifest_parser.rb', line 16

def plugin(name, options = {})
  # FIXME hardcode to install for now
  options = VPM::CommandOptions.parse!("install", options_to_args(options))
  type = options.delete(:type)
  @plugins[name] = Plugin.new(name, type, options)
end

#pluginsObject



34
35
36
# File 'lib/vpm/manifest_parser.rb', line 34

def plugins
  @plugins.values
end