module Dradis::Plugins

Public Class Methods

clear_enabled_list() click to toggle source
# File lib/dradis/plugins.rb, line 19
def clear_enabled_list
  @@enabled_list = nil
end
enabled_list() click to toggle source

Returns an array of modules representing currently enabled engines

# File lib/dradis/plugins.rb, line 15
def enabled_list
  @@enabled_list ||= @@extensions.select(&:enabled?)
end
gem_version() click to toggle source

Returns the version of the currently loaded Frontend as a Gem::Version

# File lib/dradis/plugins/gem_version.rb, line 4
def self.gem_version
  Gem::Version.new VERSION::STRING
end
list() click to toggle source

Returns an array of modules representing currently registered Dradis Plugins / engines

Example:

Dradis::Core::Plugins.list  =>  [Dradis::Core, Dradis::Frontend]
# File lib/dradis/plugins.rb, line 10
def list
  @@extensions
end
register(const) click to toggle source

Register a plugin with the framework

Example:

Dradis::Core::Plugins.register(Dradis::Core)
# File lib/dradis/plugins.rb, line 36
def register(const)
  return if registered?(const)

  validate_plugin!(const)

  @@extensions << const
end
registered?(const) click to toggle source

Returns true if a plugin is currently registered with the framework

Example:

Dradis::Core::Plugins.registered?(Dradis::Core)
# File lib/dradis/plugins.rb, line 56
def registered?(const)
  @@extensions.include?(const)
end
unregister(const) click to toggle source

Unregister a plugin from the framework

Example:

Dradis::Core::Plugins.unregister(Dradis::Core)
# File lib/dradis/plugins.rb, line 48
def unregister(const)
  @@extensions.delete(const)
end
upload_integration_names_and_modules() click to toggle source
# File lib/dradis/plugins.rb, line 60
def upload_integration_names_and_modules
  with_feature(:upload).each_with_object({}) do |integration, integrations_hash|
    integration_name = integration.plugin_name.to_s
    integration_module = integration.module_parent

    integrations_hash[integration_name] = integration_module
  end
end
version() click to toggle source

Returns the version of the currently loaded Action Mailer as a Gem::Version.

# File lib/dradis/plugins/version.rb, line 7
def self.version
  gem_version
end
with_feature(feature) click to toggle source

Filters the list of plugins and only returns those that provide the requested feature and enabled

# File lib/dradis/plugins.rb, line 25
def with_feature(feature)
  enabled_list.select do |plugin|
    # engine = "#{plugin}::Engine".constantize
    plugin.provides?(feature)
  end
end

Private Class Methods

validate_plugin!(const) click to toggle source

Use this to ensure the Extension conforms with some expected interface

# File lib/dradis/plugins.rb, line 72
def validate_plugin!(const)
  # unless const.respond_to?(:root) && const.root.is_a?(Pathname)
  #   raise InvalidEngineError, "Engine must define a root accessor that returns a pathname to its root"
  # end
end