Method: Guard::PluginUtil#initialize_plugin

Defined in:
lib/guard/plugin_util.rb

#initialize_plugin(options) ⇒ Guard::Plugin, Guard::Guard

Initializes a new Guard::Plugin with the given options hash. This methods handles plugins that inherit from the deprecated Guard::Guard class as well as plugins that inherit from Guard::Plugin.

upgrade for Guard 2.0

Returns:

  • (Guard::Plugin)

    the initialized plugin

  • (Guard::Guard)

    the initialized plugin. This return type is deprecated and the plugin’s maintainer should update it to be compatible with Guard 2.0. For more information on how to upgrade for Guard 2.0, please head over to: github.com/guard/guard/wiki/Upgrading-to-Guard-2.0

See Also:



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/guard/plugin_util.rb', line 55

def initialize_plugin(options)
  klass = plugin_class
  fail "Could not load class: #{_constant_name.inspect}" unless klass
  if klass.ancestors.include?(Guard)
    klass.new(options.delete(:watchers), options)
  else
    begin
      klass.new(**options)
    rescue ArgumentError => e
      fail "Failed to call #{klass}.new(options): #{e}"
    end
  end
end