Class: LumiaServer::Plugin

Inherits:
Object
  • Object
show all
Defined in:
lib/lumia-server/plugin.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, server_yaml) ⇒ Plugin

Returns a new instance of Plugin.



12
13
14
15
16
17
18
19
20
# File 'lib/lumia-server/plugin.rb', line 12

def initialize(data, server_yaml)
  @data = data
  @server_yaml = server_yaml

  @name = data['name']
  @version = data['version']
  @provider = data.key?('provider') ? Provider.new(@data['provider']) : nil
  @id = provider.nil? ? version : provider.id
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



4
5
6
# File 'lib/lumia-server/plugin.rb', line 4

def data
  @data
end

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/lumia-server/plugin.rb', line 10

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/lumia-server/plugin.rb', line 7

def name
  @name
end

#providerObject (readonly)

Returns the value of attribute provider.



9
10
11
# File 'lib/lumia-server/plugin.rb', line 9

def provider
  @provider
end

#server_yamlObject (readonly)

Returns the value of attribute server_yaml.



5
6
7
# File 'lib/lumia-server/plugin.rb', line 5

def server_yaml
  @server_yaml
end

#versionObject (readonly)

Returns the value of attribute version.



8
9
10
# File 'lib/lumia-server/plugin.rb', line 8

def version
  @version
end

Instance Method Details

#installObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/lumia-server/plugin.rb', line 22

def install
  unless provider.nil?
    if needs_update
      puts "#{name}: updating.."
      install_mod
    else
      puts "#{name}: up-to-date"
    end
  end
end

#install_modObject



37
38
39
# File 'lib/lumia-server/plugin.rb', line 37

def install_mod
  provider.install(File.join('build', 'plugins'))
end

#needs_updateObject



33
34
35
# File 'lib/lumia-server/plugin.rb', line 33

def needs_update
  server_yaml.nil? || server_yaml[name] != id
end