File: regexspec.rb

package info (click to toggle)
ruby-pathspec 2.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 236 kB
  • sloc: ruby: 854; makefile: 9; sh: 5
file content (23 lines) | stat: -rw-r--r-- 344 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

require 'pathspec/spec'

class PathSpec
  # Simple regex-based spec
  class RegexSpec < Spec
    def initialize(pattern)
      @pattern = pattern.dup
      @regex = Regexp.compile pattern

      super
    end

    def inclusive?
      true
    end

    def match(path)
      @regex&.match(path)
    end
  end
end