Parent

Methods

Class Index [+]

Quicksearch

Cucumber::FeatureFile

Constants

CO

Special PML markup that we want to filter out.

C_CALLOUT

Public Class Methods

new(uri, source=nil) click to toggle source

The uri argument is the location of the source. It can ba a path or a path:line1:line2 etc. If source is passed, uri is ignored.

    # File lib/cucumber/feature_file.rb, line 14
14:     def initialize(uri, source=nil)
15:       @source = source
16:       _, @path, @lines = *FILE_COLON_LINE_PATTERN.match(uri)
17:       if @path
18:         @lines = @lines.split(':').map { |line| line.to_i }
19:       else
20:         @path = uri
21:       end
22:     end

Public Instance Methods

parse(options, tag_counts) click to toggle source

Parses a file and returns a Cucumber::Ast If options contains tags, the result will be filtered.

    # File lib/cucumber/feature_file.rb, line 27
27:     def parse(options, tag_counts)
28:       filters = @lines || options.filters
29: 
30:       builder             = Cucumber::Parser::GherkinBuilder.new
31:       filter_formatter    = filters.empty? ? builder : Gherkin::Formatter::FilterFormatter.new(builder, filters)
32:       tag_count_formatter = Gherkin::Formatter::TagCountFormatter.new(filter_formatter, tag_counts)
33:       parser              = Gherkin::Parser::Parser.new(tag_count_formatter, true, "root", false)
34: 
35:       begin
36:         parser.parse(source, @path, 0)
37:         ast = builder.ast
38:         return nil if ast.nil? # Filter caused nothing to match
39:         ast.language = parser.i18n_language
40:         ast.file = @path
41:         ast
42:       rescue Gherkin::LexingError, Gherkin::Parser::ParseError => e
43:         e.message.insert(0, "#{@path}: ")
44:         raise e
45:       end
46:     end
source() click to toggle source
    # File lib/cucumber/feature_file.rb, line 48
48:     def source
49:       @source ||= if @path =~ /^http/
50:         require 'open-uri'
51:         open(@path).read
52:       else
53:         begin
54:           File.open(@path, Cucumber.file_mode('r')).read 
55:         rescue Errno::EACCES => e
56:           p = File.expand_path(@path)
57:           e.message << "\nCouldn't open #{p}"
58:           raise e
59:         end
60:       end
61:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.