Class: YARD::CodeObjects::StepDefinition
- Inherits:
-
StepTransformer
- Object
- Base
- StepTransformer
- YARD::CodeObjects::StepDefinition
- Defined in:
- lib/yard/code_objects/step_definition.rb
Constant Summary collapse
- OPTIONAL_WORD_REGEXP =
%r{(\\\s)?\\\((?!:)([^)]+)\\\)(\\s)?}
- PLACEHOLDER_REGEXP =
/(:[\w]+)/
- ALTERNATIVE_WORD_REGEXP =
/([[:alpha:]]+)((\/[[:alpha:]]+)+)/
Instance Attribute Summary collapse
-
#placeholders ⇒ Object
Returns the value of attribute placeholders.
Attributes inherited from StepTransformer
#constants, #keyword, #literal_value, #pending, #source, #steps, #substeps
Instance Method Summary collapse
Methods inherited from StepTransformer
Methods included from Cucumber::LocationHelper
#file, #line_number, #location
Instance Attribute Details
#placeholders ⇒ Object
Returns the value of attribute placeholders.
4 5 6 |
# File 'lib/yard/code_objects/step_definition.rb', line 4 def placeholders @placeholders end |
Instance Method Details
#value ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/yard/code_objects/step_definition.rb', line 10 def value unless @processed @placeholders = [] @processed = true @value = Regexp.escape(@value) @value.gsub!(PLACEHOLDER_REGEXP) do |_| find_value_for_placeholder($1) end @value.gsub!(OPTIONAL_WORD_REGEXP) do |_| [$1, $2, $3].compact.map { |m| "(?:#{m})?" }.join end @value.gsub!(ALTERNATIVE_WORD_REGEXP) do |_| "(?:#{$1}#{$2.tr('/', '|')})" end end @value end |