Class: Minfra::Cli::Plugins::Plugin

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/minfra/cli/plugin.rb

Instance Method Summary collapse

Methods included from Logging

#debug, #deprecated, #error, #exit_error, #info, #warn

Constructor Details

#initialize(spec) ⇒ Plugin

Returns a new instance of Plugin.



17
18
19
20
21
# File 'lib/minfra/cli/plugin.rb', line 17

def initialize(spec)
  @spec = spec
  @minfracs_path = Pathname.new(spec.full_gem_path).join('minfracs', 'init.rb')
  raise "no init.rb file in #{@minfracs_path}" unless @minfracs_path.exist?
end

Instance Method Details

#nameObject



9
10
11
# File 'lib/minfra/cli/plugin.rb', line 9

def name
  @spec.name
end

#setupObject



23
24
25
26
27
# File 'lib/minfra/cli/plugin.rb', line 23

def setup
  require @minfracs_path # this should register the command
rescue LoadError
  logger.warn("Minfra plugin detected but dependencies not installed: #{minfra_path} (#{$ERROR_INFO}). TRY: minfra plugin install")
end

#versionObject



13
14
15
# File 'lib/minfra/cli/plugin.rb', line 13

def version
  @spec.version
end