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:
parent
f993448fb6
commit
0fa64814b1
1 changed files with 6 additions and 0 deletions
|
@ -9,6 +9,7 @@ class Pry
|
||||||
@name, @gem_name, @enabled = name, gem_name, enabled
|
@name, @gem_name, @enabled = name, gem_name, enabled
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Disable a plugin.
|
||||||
def disable!
|
def disable!
|
||||||
self.enabled = false
|
self.enabled = false
|
||||||
end
|
end
|
||||||
|
@ -19,14 +20,18 @@ class Pry
|
||||||
@plugins = []
|
@plugins = []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Find all installed Pry plugins and store them in an internal array.
|
||||||
def locate_plugins
|
def locate_plugins
|
||||||
Gem.source_index.find_name('').each do |gem|
|
Gem.source_index.find_name('').each do |gem|
|
||||||
next if gem.name !~ PRY_PLUGIN_PREFIX
|
next if gem.name !~ PRY_PLUGIN_PREFIX
|
||||||
plugin_name = gem.name.split('-', 2).last
|
plugin_name = gem.name.split('-', 2).last
|
||||||
@plugins << Plugin.new(plugin_name, gem.name, true)
|
@plugins << Plugin.new(plugin_name, gem.name, true)
|
||||||
end
|
end
|
||||||
|
@plugins
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @return [Hash] A hash with all plugin names (minus the 'pry-') as
|
||||||
|
# keys and Plugin objects as values.
|
||||||
def plugins
|
def plugins
|
||||||
h = {}
|
h = {}
|
||||||
@plugins.each do |plugin|
|
@plugins.each do |plugin|
|
||||||
|
@ -35,6 +40,7 @@ class Pry
|
||||||
h
|
h
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Require all enabled plugins, disabled plugins are skipped.
|
||||||
def load_plugins
|
def load_plugins
|
||||||
@plugins.each do |plugin|
|
@plugins.each do |plugin|
|
||||||
require plugin.gem_name if plugin.enabled?
|
require plugin.gem_name if plugin.enabled?
|
||||||
|
|
Loading…
Reference in a new issue