Class: GitCommander::Plugin Abstract
- Inherits:
-
Object
- Object
- GitCommander::Plugin
- Defined in:
- lib/git_commander/plugin.rb,
lib/git_commander/plugin/loader.rb,
lib/git_commander/plugin/executor.rb
Overview
Allows for proxying methods to a plugin from within the context of
a Command’s block.
A Plugin provides additional external instances to a Command’s @block context. Plugins can define their own inline gems, and can define additional Commands.
Defined Under Namespace
Classes: CommandNotFound, Executor, Loader
Instance Attribute Summary collapse
-
#commands ⇒ Object
Returns the value of attribute commands.
-
#executor ⇒ Object
Returns the value of attribute executor.
-
#name ⇒ Object
Returns the value of attribute name.
-
#registry ⇒ Object
Returns the value of attribute registry.
Instance Method Summary collapse
- #find_command(command_name) ⇒ Object
-
#initialize(name, source_instance: nil, registry: nil) ⇒ Plugin
constructor
Creates a Plugin object.
Constructor Details
#initialize(name, source_instance: nil, registry: nil) ⇒ Plugin
Creates a Plugin object. name is the name of the plugin.
Options include:
source_instance - an instance of an object to use in the Command’s block context registry - a Registry instance for where this Plugin will be stored for lookup
30 31 32 33 34 |
# File 'lib/git_commander/plugin.rb', line 30 def initialize(name, source_instance: nil, registry: nil) @name = name @executor = Executor.new(source_instance) if source_instance @registry = registry || GitCommander::Registry.new end |
Instance Attribute Details
#commands ⇒ Object
Returns the value of attribute commands.
22 23 24 |
# File 'lib/git_commander/plugin.rb', line 22 def commands @commands end |
#executor ⇒ Object
Returns the value of attribute executor.
22 23 24 |
# File 'lib/git_commander/plugin.rb', line 22 def executor @executor end |
#name ⇒ Object
Returns the value of attribute name.
22 23 24 |
# File 'lib/git_commander/plugin.rb', line 22 def name @name end |
#registry ⇒ Object
Returns the value of attribute registry.
22 23 24 |
# File 'lib/git_commander/plugin.rb', line 22 def registry @registry end |
Instance Method Details
#find_command(command_name) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/git_commander/plugin.rb', line 36 def find_command(command_name) GitCommander.logger.debug "[#{logger_tag}] looking up command: #{command_name.inspect}" command = commands[command_name.to_s.to_sym] raise CommandNotFound, "[#{logger_tag}] #{command_name} does not exist for this plugin" if command.nil? command end |