Sha256: 7286e78aae767107132b7dc919e77f4dd79a9cd80b2beb2076dc413cd150c641

Contents?: true

Size: 796 Bytes

Versions: 14

Compression:

Stored size: 796 Bytes

Contents

require 'gherkin/formatter/json_formatter'
require 'gherkin/parser/parser'

module Gherkin::Formatter
  class JSONFormatter
    def to_hash
      @feature_hash
    end
  end
end

module Wally
  class ListsFeatures
    def initialize feature_path
      @feature_path = feature_path
    end

    def features
      features = []
      Dir.glob("#{@feature_path}/*.feature").each do |path|
        features << parse_gherkin(File.read(path))
      end
      features.sort {|a,b| a["name"] <=> b["name"]}
    end

    private

    def parse_gherkin(text)
      io = StringIO.new
      formatter = Gherkin::Formatter::JSONFormatter.new(io)
      parser = Gherkin::Parser::Parser.new(formatter, false, 'root')
      parser.parse(text, nil, 0)
      hash = formatter.to_hash
      hash
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
wally-0.0.17 lib/wally/lists_features.rb
wally-0.0.16 lib/wally/lists_features.rb
wally-0.0.15 lib/wally/lists_features.rb
wally-0.0.14 lib/wally/lists_features.rb
wally-0.0.13 lib/wally/lists_features.rb
wally-0.0.12 lib/wally/lists_features.rb
wally-0.0.11 lib/wally/lists_features.rb
wally-0.0.10 lib/wally/lists_features.rb
wally-0.0.9 lib/wally/lists_features.rb
wally-0.0.8 lib/wally/lists_features.rb
wally-0.0.7 lib/wally/lists_features.rb
wally-0.0.6 lib/wally/lists_features.rb
wally-0.0.5 lib/wally/lists_features.rb
wally-0.0.3 lib/wally/lists_features.rb