class SemVerComponents::Plugins

Public Class Methods

new(plugins_type) click to toggle source

Constructor

Parameters
  • plugins_type (Symbol): Plugins type we are parsing

# File lib/sem_ver_components/plugins.rb, line 9
def initialize(plugins_type)
  @plugins_type = plugins_type
  @plugins = Hash[Dir.glob("#{__dir__}/#{plugins_type}/*.rb").map do |plugin_file|
    plugin_name = File.basename(plugin_file, '.rb').to_sym
    require "#{__dir__}/#{plugins_type}/#{plugin_name}.rb"
    [
      plugin_name,
      SemVerComponents.
        const_get(plugins_type.to_s.split('_').collect(&:capitalize).join.to_sym).
        const_get(plugin_name.to_s.split('_').collect(&:capitalize).join.to_sym)
    ]
  end]
end

Public Instance Methods

[](plugin_name) click to toggle source

Get a plugin class

Parameters
  • plugin_name (Symbol): The plugin name

Result
  • Class: The corresponding plugin class

# File lib/sem_ver_components/plugins.rb, line 37
def [](plugin_name)
  @plugins[plugin_name]
end
list() click to toggle source

List available plugin names

Result
  • Array<Symbol>: Available plugin names

# File lib/sem_ver_components/plugins.rb, line 27
def list
  @plugins.keys
end