Sha256: 9a1524cd0352d55fba07ce03333856300466dd6b827cc75e651b68a1c3fce7a1

Contents?: true

Size: 852 Bytes

Versions: 1

Compression:

Stored size: 852 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

1 entries across 1 versions & 1 rubygems

Version Path
cql-0.0.2 lib/repo.rb