class Angband::GherkinFinder

Public Class Methods

new(gherkin_files) click to toggle source
# File lib/angband/gherkin_finder.rb, line 6
def initialize(gherkin_files)
  @gherkin_files = gherkin_files
end

Public Instance Methods

call(path_info) click to toggle source
# File lib/angband/gherkin_finder.rb, line 10
def call(path_info)
  listener = Angband::GherkinListener.new
  lexer = Gherkin::Lexer::I18nLexer.new(listener)

  listener.on(:tag) do |tag|
    @path_matched = true if %r{^#{tag}$} === "@#{path_info}"
  end

  result = @gherkin_files.map do |file|
    @path_matched = false
    gherkin = File.read(file)
    lexer.scan(gherkin)
    gherkin if @path_matched
  end

  result.compact
end