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 =
{}
Instance Attribute Summary collapse
-
#strictness ⇒ Object
The strictness level which this plugin would prefer the generated RBI uses.
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.
54 |
# File 'lib/parlour/plugin.rb', line 54 def initialize(); end |
Instance Attribute Details
#strictness ⇒ Object
The strictness level which this plugin would prefer the generated RBI uses. If other plugins request different strictness levels, then the lowest strictness will be used, meaning there is no guarantee that this level will be used.
70 71 72 |
# File 'lib/parlour/plugin.rb', line 70 def strictness @strictness 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 30 |
# File 'lib/parlour/plugin.rb', line 27 def self.inherited(new_plugin) Debugging.debug_puts(self, 'Registered') 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.
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/parlour/plugin.rb', line 40 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.
63 |
# File 'lib/parlour/plugin.rb', line 63 def generate(root); end |