Class: CaptainHoog::Plugin
- Inherits:
-
Object
- Object
- CaptainHoog::Plugin
- Includes:
- Delegatable
- Defined in:
- lib/captain_hoog/plugin.rb
Overview
Public: Class that evaluates a plugin from a given bunch of DSL code.
Instance Attribute Summary collapse
-
#env ⇒ Object
Returns the value of attribute env.
Instance Method Summary collapse
-
#config ⇒ Object
Public: Provides access to the configuration section in the hoogfile with the plugin’s name.
-
#eval_plugin ⇒ Object
Public: Evaluates the plugin by ‘reading’ the dsl.
-
#execute ⇒ Object
Public: Executes a plugin and stores the results in a Hash.
-
#git ⇒ Object
Public: Yields the code given in @code.
-
#initialize(code, env) ⇒ Plugin
constructor
Public: Initializes the Plugin evaluator.
Methods included from Delegatable
Constructor Details
#initialize(code, env) ⇒ Plugin
Public: Initializes the Plugin evaluator.
code - the plugin code as String env - An instance of CaptainHoog::Env containing some accessible
environment variables (context is limited to CaptainHoog)
15 16 17 18 19 |
# File 'lib/captain_hoog/plugin.rb', line 15 def initialize(code,env) @code = code @env = env @git = CaptainHoog::Git.new end |
Instance Attribute Details
#env ⇒ Object
Returns the value of attribute env.
6 7 8 |
# File 'lib/captain_hoog/plugin.rb', line 6 def env @env end |
Instance Method Details
#config ⇒ Object
Public: Provides access to the configuration section in the hoogfile with the plugin’s name.
Returns the value of the key.
49 50 51 |
# File 'lib/captain_hoog/plugin.rb', line 49 def config Struct.new(env[:plugins_config].send(git.plugin_name)) end |
#eval_plugin ⇒ Object
Public: Evaluates the plugin by ‘reading’ the dsl. Did not execute anything.
Returns nothing
30 31 32 |
# File 'lib/captain_hoog/plugin.rb', line 30 def eval_plugin instance_eval(@code) && git end |
#execute ⇒ Object
Public: Executes a plugin and stores the results in a Hash.
Returns a Hash containing the test result and the failure message.
37 38 39 40 41 42 43 |
# File 'lib/captain_hoog/plugin.rb', line 37 def execute eigenplugin.execute { :result => @git.instance_variable_get(:@test_result), :message => @git.instance_variable_get(:@message) } end |
#git ⇒ Object
Public: Yields the code given in @code.
22 23 24 |
# File 'lib/captain_hoog/plugin.rb', line 22 def git eigenplugin end |