class Parlour::Plugin

The base class for user-defined RBI generation plugins. @abstract

Attributes

strictness[RW]

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.

Public Class Methods

inherited(new_plugin) click to toggle source

Called automatically by the Ruby interpreter when {Plugin} is subclassed. This registers the new subclass into {registered_plugins}.

@param new_plugin [Plugin] The new plugin. @return [void]

# 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
new(options) click to toggle source
# File lib/parlour/plugin.rb, line 54
def initialize(options); end
registered_plugins() click to toggle source

Returns all registered plugins, as a hash of their paths to the {Plugin} instances themselves.

@return [{String, Plugin}]

# File lib/parlour/plugin.rb, line 17
def self.registered_plugins
  @@registered_plugins
end
run_plugins(plugins, generator, allow_failure: true) click to toggle source

Runs an array of plugins on a given generator instance.

@param plugins [Array<Plugin>] An array of {Plugin} instances. @param generator [RbiGenerator] The {RbiGenerator} to run the plugins on. @param allow_failure [Boolean] Whether to keep running plugins if a plugin

throws an exception. If false, the exception is re-raised when caught.

@return [void]

# 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

Public Instance Methods

generate(root) click to toggle source

Plugin subclasses should redefine this method and do their RBI generation inside it.

@abstract @param root [RbiGenerator::Namespace] The root {RbiGenerator::Namespace}. @return [void]

# File lib/parlour/plugin.rb, line 63
def generate(root); end