_match_DocStringSeparator(token, separator, is_open)
click to toggle source
def _match_DocStringSeparator(token, separator, is_open)
return false unless token.line.start_with?(separator)
content_type = nil
if is_open
content_type = token.line.get_rest_trimmed(separator.length)
@active_doc_string_separator = separator
@indent_to_remove = token.line.indent
else
@active_doc_string_separator = nil
@indent_to_remove = 0
end
set_token_matched(token, :DocStringSeparator, content_type)
true
end
match_BackgroundLine(token)
click to toggle source
def match_BackgroundLine(token)
match_title_line(token, :BackgroundLine, @dialect.background_keywords)
end
match_DocStringSeparator(token)
click to toggle source
def match_DocStringSeparator(token)
if @active_doc_string_separator.nil?
_match_DocStringSeparator(token, '"""', true) ||
_match_DocStringSeparator(token, '```', true)
else
_match_DocStringSeparator(token, @active_doc_string_separator, false)
end
end
match_EOF(token)
click to toggle source
def match_EOF(token)
return false unless token.eof?
set_token_matched(token, :EOF)
true
end
match_Empty(token)
click to toggle source
def match_Empty(token)
return false unless token.line.empty?
set_token_matched(token, :Empty, nil, nil, 0)
true
end
match_ExamplesLine(token)
click to toggle source
def match_ExamplesLine(token)
match_title_line(token, :ExamplesLine, @dialect.examples_keywords)
end
match_FeatureLine(token)
click to toggle source
def match_FeatureLine(token)
match_title_line(token, :FeatureLine, @dialect.feature_keywords)
end
match_Language(token)
click to toggle source
def match_Language(token)
return false unless token.line.trimmed_line_text =~ LANGUAGE_PATTERN
dialect_name = $1
set_token_matched(token, :Language, dialect_name)
change_dialect(dialect_name, token.location)
true
end
match_Other(token)
click to toggle source
def match_Other(token)
text = token.line.get_line_text(@indent_to_remove)
set_token_matched(token, :Other, unescape_docstring(text), nil, 0)
true
end
match_ScenarioLine(token)
click to toggle source
def match_ScenarioLine(token)
match_title_line(token, :ScenarioLine, @dialect.scenario_keywords)
end
match_ScenarioOutlineLine(token)
click to toggle source
def match_ScenarioOutlineLine(token)
match_title_line(token, :ScenarioOutlineLine, @dialect.scenario_outline_keywords)
end
match_StepLine(token)
click to toggle source
def match_StepLine(token)
keywords = @dialect.given_keywords +
@dialect.when_keywords +
@dialect.then_keywords +
@dialect.and_keywords +
@dialect.but_keywords
keyword = keywords.detect { |k| token.line.start_with?(k) }
return false unless keyword
title = token.line.get_rest_trimmed(keyword.length)
set_token_matched(token, :StepLine, title, keyword)
return true
end
match_TableRow(token)
click to toggle source
def match_TableRow(token)
return false unless token.line.start_with?('|')
set_token_matched(token, :TableRow, nil, nil, nil, token.line.table_cells)
true
end
match_TagLine(token)
click to toggle source
def match_TagLine(token)
return false unless token.line.start_with?('@')
set_token_matched(token, :TagLine, nil, nil, nil, token.line.tags)
true
end
reset()
click to toggle source
def reset
change_dialect(@default_dialect_name, nil) unless @dialect_name == @default_dialect_name
@active_doc_string_separator = nil
@indent_to_remove = 0
end