Class: VPM::Plugin

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type, options = {}) ⇒ Plugin

Returns a new instance of Plugin.



9
10
11
12
13
# File 'lib/vpm/plugin.rb', line 9

def initialize(name, type, options = {})
  @name = name
  @type = type
  @options = options
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Class Method Details

.from_hash(hash) ⇒ Object



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

def self.from_hash(hash)
  self.new(hash[:name], hash[:type], hash[:options])
end

Instance Method Details

#run_command(command) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/vpm/plugin.rb', line 15

def run_command(command)
  result = false
  plugins = VPM.plugins
  if command == "install"
    result = VPM::Commands::Install.run(self) unless plugins.installed?(name)
    plugins.plugin_installed(self) if result
  end

  result
end

#to_hashObject



32
33
34
35
36
37
38
# File 'lib/vpm/plugin.rb', line 32

def to_hash
  {
    :name => name,
    :type => type,
    :options => options
  }
end