Class: Pry::PluginManager
Defined Under Namespace
Constant Summary
- PRY_PLUGIN_PREFIX =
/^pry-/
Instance Method Summary (collapse)
- - (Boolean) gem_located?(gem_name) private
-
- (PluginManager) initialize
constructor
A new instance of PluginManager.
-
- (Object) load_plugins
Require all enabled plugins, disabled plugins are skipped.
-
- (Object) locate_plugins
Find all installed Pry plugins and store them in an internal array.
-
- (Hash) plugins
A hash with all plugin names (minus the 'pry-') as keys and Plugin objects as values.
Constructor Details
- (PluginManager) initialize
A new instance of PluginManager
63 64 65 |
# File 'lib/pry/plugins.rb', line 63 def initialize @plugins = [] end |
Instance Method Details
- (Boolean) gem_located?(gem_name) (private)
96 97 98 |
# File 'lib/pry/plugins.rb', line 96 def gem_located?(gem_name) @plugins.any? { |plugin| plugin.gem_name == gem_name } end |
- (Object) load_plugins
Require all enabled plugins, disabled plugins are skipped.
89 90 91 92 93 |
# File 'lib/pry/plugins.rb', line 89 def load_plugins @plugins.each do |plugin| plugin.activate! if plugin.enabled? end end |
- (Object) locate_plugins
Find all installed Pry plugins and store them in an internal array.
68 69 70 71 72 73 74 75 76 |
# File 'lib/pry/plugins.rb', line 68 def locate_plugins Gem.refresh (Gem::Specification.respond_to?(:each) ? Gem::Specification : Gem.source_index.find_name('')).each do |gem| next if gem.name !~ PRY_PLUGIN_PREFIX plugin_name = gem.name.split('-', 2).last @plugins << Plugin.new(plugin_name, gem.name, gem, true) if !gem_located?(gem.name) end @plugins end |
- (Hash) plugins
A hash with all plugin names (minus the 'pry-') as keys and Plugin objects as values.
80 81 82 83 84 85 86 |
# File 'lib/pry/plugins.rb', line 80 def plugins h = Hash.new { |_, key| NoPlugin.new(key) } @plugins.each do |plugin| h[plugin.name] = plugin end h end |