1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

documentation for plugins.rb

This commit is contained in:
John Mair 2011-05-16 04:19:13 +12:00
parent f993448fb6
commit 0fa64814b1

View file

@ -9,6 +9,7 @@ class Pry
@name, @gem_name, @enabled = name, gem_name, enabled
end
# Disable a plugin.
def disable!
self.enabled = false
end
@ -19,14 +20,18 @@ class Pry
@plugins = []
end
# Find all installed Pry plugins and store them in an internal array.
def locate_plugins
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, true)
end
@plugins
end
# @return [Hash] A hash with all plugin names (minus the 'pry-') as
# keys and Plugin objects as values.
def plugins
h = {}
@plugins.each do |plugin|
@ -35,6 +40,7 @@ class Pry
h
end
# Require all enabled plugins, disabled plugins are skipped.
def load_plugins
@plugins.each do |plugin|
require plugin.gem_name if plugin.enabled?