class Pry::PluginManager

Constants

PRY_PLUGIN_PREFIX

Public Class Methods

new() click to toggle source
# File lib/pry/plugins.rb, line 93
def initialize
  @plugins = []
end

Public Instance Methods

load_plugins() click to toggle source

Require all enabled plugins, disabled plugins are skipped.

# File lib/pry/plugins.rb, line 120
def load_plugins
  @plugins.each do |plugin|
    plugin.activate! if plugin.enabled?
  end
end
locate_plugins() click to toggle source

Find all installed Pry plugins and store them in an internal array.

# File lib/pry/plugins.rb, line 98
def locate_plugins
  gem_list.each do |gem|
    next if gem.name !~ PRY_PLUGIN_PREFIX

    plugin_name = gem.name.split('-', 2).last
    plugin = Plugin.new(plugin_name, gem.name, gem, false)
    @plugins << plugin.tap(&:enable!) if plugin.supported? && !plugin_located?(plugin)
  end
  @plugins
end
plugins() click to toggle source

@return [Hash] A hash with all plugin names (minus the 'pry-') as

keys and Plugin objects as values.
# File lib/pry/plugins.rb, line 111
def plugins
  h = Hash.new { |_, key| NoPlugin.new(key) }
  @plugins.each do |plugin|
    h[plugin.name] = plugin
  end
  h
end

Private Instance Methods

gem_list() click to toggle source
# File lib/pry/plugins.rb, line 132
def gem_list
  Gem.refresh
  return Gem::Specification if Gem::Specification.respond_to?(:each)

  Gem.source_index.find_name('')
end
plugin_located?(plugin) click to toggle source
# File lib/pry/plugins.rb, line 128
def plugin_located?(plugin)
  @plugins.any? { |existing| existing.gem_name == plugin.gem_name }
end