Module: CukeModeler::World
- Defined in:
- lib/cuke_modeler/world.rb
Overview
A module providing suite level analysis functionality.
Constant Summary collapse
- SANITARY_STRING =
A placeholder string used to mark ‘dirty’ portions of input strings
'___SANITIZED_BY_CUCUMBER_ANALYTICS___'- STEP_DEF_KEYWORD_PATTERN =
A pattern that matches a Cucumber step keyword
'(?:Given|When|Then|And|But)'- REGEX_PATTERN_STRING =
A pattern that matches a ‘clean’ regular expression
'\/[^\/]*\/'- STEP_DEF_LINE_PATTERN =
A pattern that matches a step definition declaration line
/^\s*#{World::STEP_DEF_KEYWORD_PATTERN}\s*\(?\s*#{REGEX_PATTERN_STRING}\s*\)?/- STEP_DEF_PATTERN_CAPTURE_PATTERN =
A pattern that captures the regular expression portion of a step definition declaration line
/^\s*#{World::STEP_DEF_KEYWORD_PATTERN}\s*\(?\s*(#{REGEX_PATTERN_STRING})\s*\)?/
Class Method Summary collapse
-
.clear_step_patterns ⇒ Object
Clears the step patterns that have been loaded into the World.
-
.delimiter=(new_delimiter) ⇒ Object
Sets the delimiter that will be used by default when determining the boundaries of step arguments.
-
.left_delimiter ⇒ Object
Returns the left delimiter, which is used to mark the beginning of a step argument.
-
.left_delimiter=(new_delimiter) ⇒ Object
Sets the left delimiter that will be used by default when determining step arguments.
-
.load_step_file(file_path) ⇒ Object
Loads the step patterns contained in the given file into the World.
-
.load_step_pattern(pattern) ⇒ Object
Loads the step pattern into the World.
-
.loaded_step_patterns ⇒ Object
Returns the step patterns that have been loaded into the World.
-
.right_delimiter ⇒ Object
Returns the right delimiter, which is used to mark the end of a step argument.
-
.right_delimiter=(new_delimiter) ⇒ Object
Sets the right delimiter that will be used by default when determining step arguments.
Class Method Details
.clear_step_patterns ⇒ Object
Clears the step patterns that have been loaded into the World.
79 80 81 |
# File 'lib/cuke_modeler/world.rb', line 79 def clear_step_patterns @defined_expressions = [] end |
.delimiter=(new_delimiter) ⇒ Object
Sets the delimiter that will be used by default when determining the boundaries of step arguments.
51 52 53 54 |
# File 'lib/cuke_modeler/world.rb', line 51 def delimiter=(new_delimiter) self.left_delimiter = new_delimiter self.right_delimiter = new_delimiter end |
.left_delimiter ⇒ Object
Returns the left delimiter, which is used to mark the beginning of a step argument.
27 28 29 |
# File 'lib/cuke_modeler/world.rb', line 27 def left_delimiter @left_delimiter end |
.left_delimiter=(new_delimiter) ⇒ Object
Sets the left delimiter that will be used by default when determining step arguments.
33 34 35 |
# File 'lib/cuke_modeler/world.rb', line 33 def left_delimiter=(new_delimiter) @left_delimiter = new_delimiter end |
.load_step_file(file_path) ⇒ Object
Loads the step patterns contained in the given file into the World.
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/cuke_modeler/world.rb', line 57 def load_step_file(file_path) File.open(file_path, 'r') do |file| file.readlines.each do |line| if step_def_line?(line) the_reg_ex = extract_regular_expression(line) loaded_step_patterns << the_reg_ex end end end end |
.load_step_pattern(pattern) ⇒ Object
Loads the step pattern into the World.
69 70 71 |
# File 'lib/cuke_modeler/world.rb', line 69 def load_step_pattern(pattern) loaded_step_patterns << pattern end |
.loaded_step_patterns ⇒ Object
Returns the step patterns that have been loaded into the World.
74 75 76 |
# File 'lib/cuke_modeler/world.rb', line 74 def loaded_step_patterns @defined_expressions ||= [] end |
.right_delimiter ⇒ Object
Returns the right delimiter, which is used to mark the end of a step argument.
39 40 41 |
# File 'lib/cuke_modeler/world.rb', line 39 def right_delimiter @right_delimiter end |
.right_delimiter=(new_delimiter) ⇒ Object
Sets the right delimiter that will be used by default when determining step arguments.
45 46 47 |
# File 'lib/cuke_modeler/world.rb', line 45 def right_delimiter=(new_delimiter) @right_delimiter = new_delimiter end |