Class: Pry::PluginManager::Plugin
Instance Attribute Summary (collapse)
-
- (Object) active
(also: #active?)
Returns the value of attribute active.
-
- (Object) enabled
(also: #enabled?)
Returns the value of attribute enabled.
-
- (Object) gem_name
Returns the value of attribute gem_name.
-
- (Object) name
Returns the value of attribute name.
-
- (Object) spec
Returns the value of attribute spec.
Instance Method Summary (collapse)
-
- (Object) activate!
Activate the plugin (require the gem - enables/loads the plugin immediately at point of call, even if plugin is disabled) Does not reload plugin if it's already active.
-
- (Object) disable!
Disable a plugin.
-
- (Object) enable!
Enable a plugin.
-
- (Plugin) initialize(name, gem_name, spec, enabled)
constructor
A new instance of Plugin.
-
- (Object) load_cli_options
Load the Command line options defined by this plugin (if they exist).
Constructor Details
- (Plugin) initialize(name, gem_name, spec, enabled)
A new instance of Plugin
19 20 21 |
# File 'lib/pry/plugins.rb', line 19 def initialize(name, gem_name, spec, enabled) @name, @gem_name, @enabled, @spec = name, gem_name, enabled, spec end |
Instance Attribute Details
- (Object) active Also known as: active?
Returns the value of attribute active
17 18 19 |
# File 'lib/pry/plugins.rb', line 17 def active @active end |
- (Object) enabled Also known as: enabled?
Returns the value of attribute enabled
17 18 19 |
# File 'lib/pry/plugins.rb', line 17 def enabled @enabled end |
- (Object) gem_name
Returns the value of attribute gem_name
17 18 19 |
# File 'lib/pry/plugins.rb', line 17 def gem_name @gem_name end |
- (Object) name
Returns the value of attribute name
17 18 19 |
# File 'lib/pry/plugins.rb', line 17 def name @name end |
- (Object) spec
Returns the value of attribute spec
17 18 19 |
# File 'lib/pry/plugins.rb', line 17 def spec @spec end |
Instance Method Details
- (Object) activate!
Activate the plugin (require the gem - enables/loads the plugin immediately at point of call, even if plugin is disabled) Does not reload plugin if it's already active.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/pry/plugins.rb', line 44 def activate! # Create the configuration object for the plugin. Pry.config.send("#{gem_name.gsub('-', '_')}=", OpenStruct.new) begin require gem_name if !active? rescue LoadError => e warn "Warning: The plugin '#{gem_name}' was not found! (gem found but could not be loaded)" warn e end self.active = true self.enabled = true end |
- (Object) disable!
Disable a plugin. (prevents plugin from being loaded, cannot disable an already activated plugin)
25 26 27 |
# File 'lib/pry/plugins.rb', line 25 def disable! self.enabled = false end |
- (Object) enable!
Enable a plugin. (does not load it immediately but puts on 'white list' to be loaded)
31 32 33 |
# File 'lib/pry/plugins.rb', line 31 def enable! self.enabled = true end |
- (Object) load_cli_options
Load the Command line options defined by this plugin (if they exist)
36 37 38 39 |
# File 'lib/pry/plugins.rb', line 36 def = File.join(spec.full_gem_path, "lib/#{spec.name}/cli.rb") require if File.exists?() end |