Class: Parlour::Plugin Abstract
- Inherits:
-
Object
- Object
- Parlour::Plugin
- Extended by:
- T::Helpers, T::Sig
- Defined in:
- lib/parlour/plugin.rb
Overview
The base class for user-defined RBI generation plugins.
Constant Summary collapse
- @@registered_plugins =
{}
Class Method Summary collapse
-
.inherited(new_plugin) ⇒ void
Called automatically by the Ruby interpreter when Plugin is subclassed.
-
.registered_plugins ⇒ {String, Plugin}
Returns all registered plugins, as a hash of their paths to the Plugin instances themselves.
-
.run_plugins(plugins, generator, allow_failure: true) ⇒ void
Runs an array of plugins on a given generator instance.
Instance Method Summary collapse
-
#generate(root) ⇒ void
abstract
Plugin subclasses should redefine this method and do their RBI generation inside it.
-
#initialize(options) ⇒ Plugin
constructor
A new instance of Plugin.
Constructor Details
#initialize(options) ⇒ Plugin
Returns a new instance of Plugin.
53 |
# File 'lib/parlour/plugin.rb', line 53 def initialize(); end |
Class Method Details
.inherited(new_plugin) ⇒ void
This method returns an undefined value.
Called automatically by the Ruby interpreter when Parlour::Plugin is subclassed. This registers the new subclass into registered_plugins.
27 28 29 |
# File 'lib/parlour/plugin.rb', line 27 def self.inherited(new_plugin) registered_plugins[T.must(new_plugin.name)] = new_plugin end |
.registered_plugins ⇒ {String, Plugin}
Returns all registered plugins, as a hash of their paths to the Parlour::Plugin instances themselves.
17 18 19 |
# File 'lib/parlour/plugin.rb', line 17 def self.registered_plugins @@registered_plugins end |
.run_plugins(plugins, generator, allow_failure: true) ⇒ void
This method returns an undefined value.
Runs an array of plugins on a given generator instance.
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/parlour/plugin.rb', line 39 def self.run_plugins(plugins, generator, allow_failure: true) plugins.each do |plugin| begin puts "=== #{plugin.class.name}" generator.current_plugin = plugin plugin.generate(generator.root) rescue Exception => e raise e unless allow_failure puts "!!! This plugin threw an exception: #{e}" end end end |
Instance Method Details
#generate(root) ⇒ void
This method returns an undefined value.
Plugin subclasses should redefine this method and do their RBI generation inside it.
62 |
# File 'lib/parlour/plugin.rb', line 62 def generate(root); end |