Sha256: d82c88250ffeb9fe390ba890cd8b4b527423d4974c691ee11c83dd09c0814b58

Contents?: true

Size: 819 Bytes

Versions: 2

Compression:

Stored size: 819 Bytes

Contents

require 'gherkin/parser/parser'
require 'gherkin/formatter/json_formatter'
require 'stringio'
require File.dirname(__FILE__) + "/dsl"

module CQL
  class Repository
    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

2 entries across 2 versions & 1 rubygems

Version Path
cql-0.1.2 lib/repo.rb
cql-0.1.0.1 lib/repo.rb