Sha256: c6e33a3cec176e1babbe34a05832351dc3edc7be4af326269001c4e45c3421cf

Contents?: true

Size: 770 Bytes

Versions: 8

Compression:

Stored size: 770 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 features
      features = []
      Feature.all.each do |feature|
        gherkinese = parse_gherkin(feature.content)
        gherkinese["path"] = feature.path
        features << gherkinese
      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

8 entries across 8 versions & 1 rubygems

Version Path
wally-0.0.28 lib/wally/lists_features.rb
wally-0.0.27 lib/wally/lists_features.rb
wally-0.0.26 lib/wally/lists_features.rb
wally-0.0.25 lib/wally/lists_features.rb
wally-0.0.24 lib/wally/lists_features.rb
wally-0.0.22 lib/wally/lists_features.rb
wally-0.0.21 lib/wally/lists_features.rb
wally-0.0.20 lib/wally/lists_features.rb