Sha256: 69574cef1cd33f64dfc0c66e8c9ed4c6dd5fac07f81cb1ba0587068b32050160

Contents?: true

Size: 948 Bytes

Versions: 1

Compression:

Stored size: 948 Bytes

Contents

require 'gherkin/parser/parser'
require 'gherkin/formatter/json_formatter'
require 'stringio'
require 'json'
require 'set'

require File.dirname(__FILE__) + "/gherkin_map_reduce"
require File.dirname(__FILE__) + "/dsl"

module CQL
  class GherkinRepository
    include Dsl
    attr_reader :parsed_feature_files

    def initialize features_home_dir
      @parsed_feature_files = load_features(list_features(features_home_dir))
    end

    def query &block
      Query.new(parsed_feature_files.clone, &block).data
    end

    private
    def list_features base_dir
      Dir.glob(base_dir + "/**/*.feature")
    end

    def load_features sources
      io = StringIO.new
      formatter = Gherkin::Formatter::JSONFormatter.new(io)
      parser = Gherkin::Parser::Parser.new(formatter)
      sources.each { |s| parser.parse(IO.read(s), s, 0) }
      formatter.done
      JSON.parse(io.string)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cql-0.0.1 lib/gherkin_repo.rb