Class: RgGen::Core::Builder::PluginManager

Inherits:
Object
  • Object
show all
Defined in:
lib/rggen/core/builder/plugin_manager.rb

Instance Method Summary collapse

Constructor Details

#initialize(builder) ⇒ PluginManager

Returns a new instance of PluginManager.



59
60
61
62
# File 'lib/rggen/core/builder/plugin_manager.rb', line 59

def initialize(builder)
  @builder = builder
  @plugins = []
end

Instance Method Details

#activate_plugin_by_name(plugin_name) ⇒ Object



85
86
87
88
89
90
91
# File 'lib/rggen/core/builder/plugin_manager.rb', line 85

def activate_plugin_by_name(plugin_name)
  @plugins.find { |plugin| plugin.name == plugin_name }
    &.then do |plugin|
      plugin.activate(@builder)
      plugin.activate_additionally(@builder)
    end
end

#activate_pluginsObject



80
81
82
83
# File 'lib/rggen/core/builder/plugin_manager.rb', line 80

def activate_plugins
  do_normal_activation
  do_addtional_activation
end

#load_plugin(path_or_name, version = nil) ⇒ Object



64
65
66
67
# File 'lib/rggen/core/builder/plugin_manager.rb', line 64

def load_plugin(path_or_name, version = nil)
  info = PluginInfo.parse(path_or_name, version)
  read_plugin_file(info)
end

#load_plugins(plugins, no_default_plugins, activation = true) ⇒ Object



69
70
71
72
73
74
# File 'lib/rggen/core/builder/plugin_manager.rb', line 69

def load_plugins(plugins, no_default_plugins, activation = true)
  RgGen.builder(@builder)
  merge_plugins(plugins, no_default_plugins)
    .each { |plugin| load_plugin(*plugin) }
  activation && activate_plugins
end

#setup_plugin(plugin_name, &block) ⇒ Object



76
77
78
# File 'lib/rggen/core/builder/plugin_manager.rb', line 76

def setup_plugin(plugin_name, &block)
  @plugins << PluginSpec.new(plugin_name, &block)
end

#version_infoObject



93
94
95
# File 'lib/rggen/core/builder/plugin_manager.rb', line 93

def version_info
  @plugins.map(&:version_info)
end