Class: Lolcommits::Plugin
- Inherits:
-
Object
- Object
- Lolcommits::Plugin
- Includes:
- Methadone::CLILogging
- Defined in:
- lib/lolcommits/plugin.rb
Instance Attribute Summary collapse
-
#default ⇒ Object
Returns the value of attribute default.
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
-
#runner ⇒ Object
Returns the value of attribute runner.
Instance Method Summary collapse
- #configuration ⇒ Object
- #execute ⇒ Object
-
#initialize(runner) ⇒ Plugin
constructor
A new instance of Plugin.
- #is_enabled? ⇒ Boolean
-
#plugdebug(msg) ⇒ Object
uniform debug logging output for plugins.
Constructor Details
#initialize(runner) ⇒ Plugin
Returns a new instance of Plugin.
12 13 14 15 16 17 |
# File 'lib/lolcommits/plugin.rb', line 12 def initialize(runner) self.runner = runner self. = ['enabled'] plugdebug "Initializing" end |
Instance Attribute Details
#default ⇒ Object
Returns the value of attribute default.
4 5 6 |
# File 'lib/lolcommits/plugin.rb', line 4 def default @default end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/lolcommits/plugin.rb', line 4 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
4 5 6 |
# File 'lib/lolcommits/plugin.rb', line 4 def @options end |
#runner ⇒ Object
Returns the value of attribute runner.
4 5 6 |
# File 'lib/lolcommits/plugin.rb', line 4 def runner @runner end |
Instance Method Details
#configuration ⇒ Object
6 7 8 9 10 |
# File 'lib/lolcommits/plugin.rb', line 6 def configuration config = runner.config.user_configuration return Hash.new if config.nil? config[self.name] || Hash.new end |
#execute ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/lolcommits/plugin.rb', line 26 def execute if is_enabled? plugdebug "I am enabled, about to run" run else plugdebug "Disabled, doing nothing for execution" end end |
#is_enabled? ⇒ Boolean
19 20 21 22 23 |
# File 'lib/lolcommits/plugin.rb', line 19 def is_enabled? enabled_config = configuration['enabled'] return self.default if enabled_config.nil? || enabled_config == '' return enabled_config end |
#plugdebug(msg) ⇒ Object
uniform debug logging output for plugins
36 37 38 |
# File 'lib/lolcommits/plugin.rb', line 36 def plugdebug(msg) debug("Plugin: #{self.class.to_s}: " + msg) end |