Class: Cucumber::FeatureFile
Constant Summary collapse
- FILE_COLON_LINE_PATTERN =
/^([\w\W]*?):([\d:]+)$/
- LANGUAGE_PATTERN =
/language:\s*(.*)/
Instance Method Summary collapse
-
#initialize(uri, source = nil) ⇒ FeatureFile
constructor
The
uri
argument can ba a path or a path:line1:line2 etc. - #lang ⇒ Object
-
#parse(options = {}) ⇒ Object
Parses a file and returns a Cucumber::Ast If
options
contains tags, the result will be filtered. - #source ⇒ Object
Constructor Details
#initialize(uri, source = nil) ⇒ FeatureFile
The uri
argument can ba a path or a path:line1:line2 etc.
10 11 12 13 14 15 16 17 18 |
# File 'lib/cucumber/feature_file.rb', line 10 def initialize(uri, source=nil) @source = source _, @path, @lines = *FILE_COLON_LINE_PATTERN.match(uri) if @path @lines = @lines.split(':').map { |line| line.to_i } else @path = uri end end |
Instance Method Details
#lang ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/cucumber/feature_file.rb', line 38 def lang line_one = source.split(/\n/)[0] if line_one =~ LANGUAGE_PATTERN $1.strip else nil end end |
#parse(options = {}) ⇒ Object
Parses a file and returns a Cucumber::Ast If options
contains tags, the result will be filtered.
23 24 25 26 27 |
# File 'lib/cucumber/feature_file.rb', line 23 def parse(={}) filter = Filter.new(@lines, ) language = Parser::I18n::Language[lang || [:lang] || 'en'] language.parse(source, @path, filter) end |