Class: YARD::CodeObjects::StepTransformerObject
- Inherits:
-
Base
- Object
- Base
- YARD::CodeObjects::StepTransformerObject
- Includes:
- Cucumber::LocationHelper
- Defined in:
- lib/yard/code_objects/step_transformer.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#constants ⇒ Object
readonly
Returns the value of attribute constants.
-
#keyword ⇒ Object
readonly
Returns the value of attribute keyword.
-
#literal_value ⇒ Object
readonly
Returns the value of attribute literal_value.
-
#pending ⇒ Object
Returns the value of attribute pending.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#steps ⇒ Object
Returns the value of attribute steps.
-
#substeps ⇒ Object
Returns the value of attribute substeps.
-
#value ⇒ Object
When requesting a step tranformer object value, process it, if it hasn’t alredy been processed, replacing any constants that may be lurking within the value.
Instance Method Summary collapse
-
#constants_from_value(data = @value) ⇒ Object
Look through the specified data for the escape pattern and return an array of those constants found.
-
#escape_pattern ⇒ Object
This defines an escape pattern within a string or regex: /^the first #CONSTANT step$/.
-
#regex ⇒ Object
Generate a regex with the step transformers value.
Methods included from Cucumber::LocationHelper
#file, #line_number, #location
Instance Attribute Details
#constants ⇒ Object (readonly)
Returns the value of attribute constants.
6 7 8 |
# File 'lib/yard/code_objects/step_transformer.rb', line 6 def constants @constants end |
#keyword ⇒ Object (readonly)
Returns the value of attribute keyword.
6 7 8 |
# File 'lib/yard/code_objects/step_transformer.rb', line 6 def keyword @keyword end |
#literal_value ⇒ Object (readonly)
Returns the value of attribute literal_value.
6 7 8 |
# File 'lib/yard/code_objects/step_transformer.rb', line 6 def literal_value @literal_value end |
#pending ⇒ Object
Returns the value of attribute pending.
7 8 9 |
# File 'lib/yard/code_objects/step_transformer.rb', line 7 def pending @pending end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
6 7 8 |
# File 'lib/yard/code_objects/step_transformer.rb', line 6 def source @source end |
#steps ⇒ Object
Returns the value of attribute steps.
7 8 9 |
# File 'lib/yard/code_objects/step_transformer.rb', line 7 def steps @steps end |
#substeps ⇒ Object
Returns the value of attribute substeps.
7 8 9 |
# File 'lib/yard/code_objects/step_transformer.rb', line 7 def substeps @substeps end |
#value ⇒ Object
When requesting a step tranformer object value, process it, if it hasn’t alredy been processed, replacing any constants that may be lurking within the value.
Processing it means looking for any escaped characters that happen to be CONSTANTS that could be matched and then replaced. This is done recursively as CONSTANTS can be defined with more CONSTANTS.
31 32 33 |
# File 'lib/yard/code_objects/step_transformer.rb', line 31 def value @value end |
Instance Method Details
#constants_from_value(data = @value) ⇒ Object
Look through the specified data for the escape pattern and return an array of those constants found. This defaults to the @value within step transformer as it is used internally, however, it can be called externally if it’s needed somewhere.
68 69 70 |
# File 'lib/yard/code_objects/step_transformer.rb', line 68 def constants_from_value(data=@value) data.scan(escape_pattern).flatten.collect { |value| value.strip } end |
#escape_pattern ⇒ Object
this does not handle the result of method calls
this does not handle multiple constants within the same escaped area
This defines an escape pattern within a string or regex:
/^the first #{CONSTANT} step$/
This is used below in the value to process it if there happen to be constants defined here.
18 19 20 |
# File 'lib/yard/code_objects/step_transformer.rb', line 18 def escape_pattern /#\{\s*(\w+)\s*\}/ end |
#regex ⇒ Object
Generate a regex with the step transformers value
60 61 62 |
# File 'lib/yard/code_objects/step_transformer.rb', line 60 def regex @regex ||= /#{strip_regex_from(value)}/ end |