class Cucumber::FeatureFile
def initialize(uri, source=nil)
The +uri+ argument is the location of the source. It can ba a path
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
def lang
def lang line_one = source.split(/\n/)[0] if line_one =~ LANGUAGE_PATTERN $1.strip else nil end end
def parse(step_mother, options)
If +options+ contains tags, the result will
Parses a file and returns a Cucumber::Ast
def parse(step_mother, options) filter = Filter.new(@lines, options) language = Parser::NaturalLanguage.get(step_mother, (lang || 'en')) language.parse(source, @path, filter) end
def source
def source @source ||= if @path =~ /^http/ require 'open-uri' open(@path).read else begin File.open(@path, Cucumber.file_mode('r')).read rescue Errno::EACCES => e p = File.expand_path(@path) e.message << "\nCouldn't open #{p}" raise e end end end