class Koine::TestRunner::FileMatcher

Constants

NoMatchError

Public Class Methods

new(file_path:) click to toggle source
# File lib/koine/test_runner/file_matcher.rb, line 6
def initialize(file_path:)
  @lines = File.readlines(file_path)
end

Public Instance Methods

above_line(line, regexp:) click to toggle source
# File lib/koine/test_runner/file_matcher.rb, line 10
def above_line(line, regexp:)
  length = @lines.length
  slice = length - line
  lines = @lines.reverse.slice(slice, length)
  lines.each do |file_line|
    match = regexp.match(file_line)
    return match if match
  end

  raise NoMatchError
end