Class: Pluginator::Autodetect

Inherits:
Group
  • Object
show all
Includes:
NameConverter
Defined in:
lib/pluginator/autodetect.rb,
lib/pluginator/autodetect.rb,
lib/pluginator/autodetect/finder.rb,
lib/pluginator/autodetect/formatted_finder.rb

Overview

Add autodetection capabilities to Group

See Also:

  • FormattedFinder

Direct Known Subclasses

ExtendableAutodetect

Defined Under Namespace

Classes: Finder, FormattedFinder

Instance Attribute Summary

Attributes inherited from Group

#group

Instance Method Summary collapse

Methods inherited from Group

#[], #register_plugin, #types

Constructor Details

#initialize(group, options = {}) ⇒ Autodetect

Automatically load plugins for given group (and type)

Parameters:

  • group (String)

    name of the plugins group

  • options (Hash) (defaults to: {})

    options to pass to creating Pluginator instance

  • type (Hash)

    a customizable set of options

  • prefix (Hash)

    a customizable set of options



45
46
47
48
49
50
# File 'lib/pluginator/autodetect.rb', line 45

def initialize(group, options={})
  super(group)
  @force_prefix = options[:prefix]
  @force_type   = options[:type]
  refresh
end

Instance Method Details

#refreshObject

Initiate another lookup for plugins

  • does not clean the state

  • does not resolve all gems, only the new ones

Use it after gem list change, for example after ‘Gem.install(“new_gem”)`



57
58
59
60
61
62
# File 'lib/pluginator/autodetect.rb', line 57

def refresh
  plugin_lists = FormattedFinder.new(@force_prefix, @group, @force_type)
  register_plugins(plugin_lists.loaded_plugins_path)
  load_plugins(plugin_lists.load_path_plugins_paths)
  activate_plugins(plugin_lists.gem_plugins_paths)
end

#typeObject

Return the forced type



65
66
67
# File 'lib/pluginator/autodetect.rb', line 65

def type
  @plugins[@force_type] unless @force_type.nil?
end