class PowerStencil::Plugins::Base
Attributes
entry_point_path[R]
gem_spec[R]
name[R]
project[R]
version[R]
Public Class Methods
new(name, project, type: :local, gem_req: nil)
click to toggle source
# File lib/power_stencil/plugins/base.rb, line 35 def initialize(name, project, type: :local, gem_req: nil) @name = name @project = project @version = PowerStencil::Utils::SemanticVersion.new '0.0.0-not-specified' raise PowerStencil::Error, "Invalid plugin type (#{type}) for plugin '#{name}'" unless PLUGIN_TYPES.include? type @type = type case type when :gem logger.debug "Plugin '#{name}' is provided as a Gem." @gem_spec = PowerStencil::Plugins::Base.find_locally_installed_gem_spec name, gem_req raise PowerStencil::Error, "Cannot find plugin '#{name}'. Try 'power_stencil plugin --install'" if gem_spec.nil? raise PowerStencil::Error, "Invalid plugin '#{name}' ! Missing metadata 'plugin_name' in spec !" if gem_spec.metadata['plugin_name'].nil? logger.debug "Plugin '#{name}' real name is '#{gem_spec.metadata['plugin_name']}'." @name = gem_spec.metadata['plugin_name'] when :local logger.debug "Plugin '#{name}' is provided locally by the project." else raise PowerStencil::Error, "Unsupported plugin type (#{type}) for plugin '#{name}' !" end logger.debug "Loading plugin '#{name}'..." setup_plugin logger.info "Plugin '#{name}' successfully available" logger.debug "Plugin '#{name}' has following capabilities: #{capabilities.inspect}" end
Public Instance Methods
plugin_module()
click to toggle source
# File lib/power_stencil/plugins/base.rb, line 61 def plugin_module Object.const_get plugin_definition[:plugin_module] end
Private Instance Methods
setup_plugin()
click to toggle source
# File lib/power_stencil/plugins/base.rb, line 69 def setup_plugin determine_capabilities load_plugin_specific_config load_yaml_command_definition end