Class: YARD::CodeObjects::StepDefinition

Inherits:
StepTransformer show all
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

Attributes inherited from StepTransformer

#constants, #keyword, #literal_value, #pending, #source, #steps, #substeps

Instance Method Summary collapse

Methods inherited from StepTransformer

#regex

Methods included from Cucumber::LocationHelper

#file, #line_number, #location

Instance Attribute Details

#placeholdersObject

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

#valueObject



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