Sha256: a70152c02a64ac97024da05a1926ee3d8b1887feba47cb983cdf3b24aa284f38

Contents?: true

Size: 512 Bytes

Versions: 7

Compression:

Stored size: 512 Bytes

Contents

module Koine
  class TestRunner
    class FileMatcher
      NoMatchError = Class.new(RuntimeError)

      def initialize(file_path:)
        @lines = File.readlines(file_path)
      end

      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
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
koine-test_runner-0.4.0 lib/koine/test_runner/file_matcher.rb
koine-test_runner-0.3.0 lib/koine/test_runner/file_matcher.rb
koine-test_runner-0.2.4 lib/koine/test_runner/file_matcher.rb
koine-test_runner-0.2.3 lib/koine/test_runner/file_matcher.rb
koine-test_runner-0.2.2 lib/koine/test_runner/file_matcher.rb
koine-test_runner-0.2.1 lib/koine/test_runner/file_matcher.rb
koine-test_runner-0.2.0 lib/koine/test_runner/file_matcher.rb