Class: CukeSniffer::Hook
- Inherits:
-
RuleTarget
- Object
- RuleTarget
- CukeSniffer::Hook
- Defined in:
- lib/cuke_sniffer/hook.rb
Overview
- Author
-
Robert Cochran ([email protected])
- Copyright
-
Copyright © 2013 Robert Cochran
- License
-
Distributes under the MIT License
Cucumber Hook class used for evaluating rules Extends CukeSniffer::RulesEvaluator
Constant Summary
Constants included from RuleConfig
RuleConfig::ERROR, RuleConfig::FATAL, RuleConfig::INFO, RuleConfig::RULES, RuleConfig::WARNING
Constants included from Constants
Constants::COMMENT_REGEX, Constants::DATE_REGEX, Constants::DEFAULT_OUTPUT_FILE_NAME, Constants::FILE_IGNORE_LIST, Constants::HOOK_REGEX, Constants::HOOK_STYLES, Constants::MARKUP_SOURCE, Constants::SCENARIO_TITLE_STYLES, Constants::STEP_DEFINITION_REGEX, Constants::STEP_REGEX, Constants::STEP_STYLES, Constants::TAG_REGEX, Constants::THRESHOLDS
Instance Attribute Summary collapse
-
#code ⇒ Object
Array of strings that contain the code kept in the hook.
-
#parameters ⇒ Object
The parameters that are declared on the hook.
-
#start_line ⇒ Object
Integer of the line in which the hook was found.
-
#tags ⇒ Object
The list of tags used as a filter for the hook.
-
#type ⇒ Object
The type of the hook: AfterConfiguration, After, AfterStep, Around, Before, at_exit.
Attributes inherited from RuleTarget
#location, #rules_hash, #score
Instance Method Summary collapse
-
#==(comparison_object) ⇒ Object
:nodoc:.
-
#initialize(location, hook_block) ⇒ Hook
constructor
location must be in the format of “file_pathfile_name.rb:line_number” raw_code is an array of strings that represents the step definition must contain the hook declaration line and the pairing end.
Methods inherited from RuleTarget
Constructor Details
#initialize(location, hook_block) ⇒ Hook
location must be in the format of “file_pathfile_name.rb:line_number” raw_code is an array of strings that represents the step definition must contain the hook declaration line and the pairing end
36 37 38 39 40 41 42 |
# File 'lib/cuke_sniffer/hook.rb', line 36 def initialize(location, hook_block) super(location) @start_line = location.match(/:(?<line>\d*)$/)[:line].to_i end_match_index = (hook_block.size - 1) - hook_block.reverse.index("end") @code = hook_block[1...end_match_index] initialize_hook_signature(hook_block) end |
Instance Attribute Details
#code ⇒ Object
Array of strings that contain the code kept in the hook
30 31 32 |
# File 'lib/cuke_sniffer/hook.rb', line 30 def code @code end |
#parameters ⇒ Object
The parameters that are declared on the hook
24 25 26 |
# File 'lib/cuke_sniffer/hook.rb', line 24 def parameters @parameters end |
#start_line ⇒ Object
Integer of the line in which the hook was found
27 28 29 |
# File 'lib/cuke_sniffer/hook.rb', line 27 def start_line @start_line end |
#tags ⇒ Object
The list of tags used as a filter for the hook
21 22 23 |
# File 'lib/cuke_sniffer/hook.rb', line 21 def end |
#type ⇒ Object
The type of the hook: AfterConfiguration, After, AfterStep, Around, Before, at_exit
18 19 20 |
# File 'lib/cuke_sniffer/hook.rb', line 18 def type @type end |
Instance Method Details
#==(comparison_object) ⇒ Object
:nodoc:
44 45 46 47 48 49 50 |
# File 'lib/cuke_sniffer/hook.rb', line 44 def ==(comparison_object) # :nodoc: super(comparison_object) && comparison_object.type == type && comparison_object. == && comparison_object.parameters == parameters && comparison_object.code == code end |