Class: Minfra::Cli::Plugins

Inherits:
Object
  • Object
show all
Defined in:
lib/minfra/cli/plugin.rb,
lib/minfra/cli/plugins.rb

Defined Under Namespace

Classes: Plugin

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(plugins) ⇒ Plugins

Returns a new instance of Plugins.



7
8
9
# File 'lib/minfra/cli/plugins.rb', line 7

def initialize(plugins)
  @plugins = plugins
end

Class Method Details

.load(base_path) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/minfra/cli/plugins.rb', line 23

def self.load(base_path)
  found = []
  [base_path.join('config', 'minfra_plugins.json'),
   base_path.join('me', 'minfra_plugins.json')].each do |file|
    next unless File.exist?(file)

    plugins = JSON.parse(File.read(file))
    plugins['plugins'].each do |spec|
      found << Plugin.new(name: spec['name'], opts: spec['opts'] || {}, version: spec['version'],
                          disabled: spec['disabled'])
    end
  end
  new(found)
end

Instance Method Details

#eachObject



19
20
21
# File 'lib/minfra/cli/plugins.rb', line 19

def each(&)
  @plugins.each(&)
end

#prepareObject



11
12
13
# File 'lib/minfra/cli/plugins.rb', line 11

def prepare
  @plugins.each(&:prepare)
end

#setupObject



15
16
17
# File 'lib/minfra/cli/plugins.rb', line 15

def setup
  @plugins.each(&:setup)
end