Module: MiGA::Project::Plugins

Included in:
MiGA::Project
Defined in:
lib/miga/project/plugins.rb

Overview

Helper module including specific functions handle plugins.

Instance Method Summary collapse

Instance Method Details

#install_plugin(path) ⇒ Object

Installs the plugin in the specified path.


10
11
12
13
14
15
16
17
18
19
# File 'lib/miga/project/plugins.rb', line 10

def install_plugin(path)
  abs_path = File.absolute_path(path)
  raise "Plugin already installed in project: #{abs_path}." unless
    [:plugins].nil? or not [:plugins].include?(abs_path)
  raise "Malformed MiGA plugin: #{abs_path}." unless
    File.exist?(File.expand_path("miga-plugin.json", abs_path))
  self.[:plugins] ||= []
  self.[:plugins] << abs_path
  save
end

#load_pluginsObject

Loads the plugins installed in the project.


37
38
39
# File 'lib/miga/project/plugins.rb', line 37

def load_plugins
  plugins.each { |pl| require File.expand_path("lib-plugin.rb", pl) }
end

#pluginsObject

List plugins installed in the project.


33
# File 'lib/miga/project/plugins.rb', line 33

def plugins ; [:plugins] ||= [] ; end

#uninstall_plugin(path) ⇒ Object

Uninstall the plugin in the specified path.


23
24
25
26
27
28
29
# File 'lib/miga/project/plugins.rb', line 23

def uninstall_plugin(path)
  abs_path = File.absolute_path(path)
  raise "Plugin not currently installed: #{abs_path}." if
    [:plugins].nil? or not [:plugins].include?(abs_path)
  self.[:plugins].delete(abs_path)
  save
end