class CaptainHoog::Plugin
Public: Class that evaluates a plugin from a given bunch of DSL code.
Attributes
env[RW]
Public Class Methods
new(code,env)
click to toggle source
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)
# File lib/captain_hoog/plugin.rb, line 15 def initialize(code,env) @code = code @env = env @git = CaptainHoog::Git.new end
Public Instance Methods
config()
click to toggle source
Public: Provides access to the configuration section in the hoogfile with the plugin's name.
Returns the value of the key.
# File lib/captain_hoog/plugin.rb, line 49 def config Struct.new(env[:plugins_config].send(git.plugin_name)) end
eval_plugin()
click to toggle source
Public: Evaluates the plugin by 'reading' the dsl. Did not execute anything.
Returns nothing
# File lib/captain_hoog/plugin.rb, line 30 def eval_plugin instance_eval(@code) && git end
execute()
click to toggle source
Public: Executes a plugin and stores the results in a Hash
.
Returns a Hash
containing the test result and the failure message.
# 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()
click to toggle source
Public: Yields the code given in @code.
# File lib/captain_hoog/plugin.rb, line 22 def git eigenplugin end
Private Instance Methods
describe(name) { |git| ... }
click to toggle source
# File lib/captain_hoog/plugin.rb, line 66 def describe(name) @plugin_name = name yield(@git) if block_given? end
eigenplugin()
click to toggle source
# File lib/captain_hoog/plugin.rb, line 55 def eigenplugin @eigenplugin ||= Class.new do include Delegatable attr_reader :plugin_name delegate_to :git def initialize(git) @git = git end def describe(name) @plugin_name = name yield(@git) if block_given? end end.new(@git) end