File: pattern.rb

package info (click to toggle)
ruby-guard 2.18.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,344 kB
  • sloc: ruby: 9,256; makefile: 6
file content (24 lines) | stat: -rw-r--r-- 658 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
require "guard/ui"

require_relative "pattern/match_result"
require_relative "pattern/matcher"
require_relative "pattern/deprecated_regexp"
require_relative "pattern/simple_path"
require_relative "pattern/pathname_path"

module Guard
  class Watcher
    class Pattern
      def self.create(pattern)
        if DeprecatedRegexp.new(pattern).deprecated?
          DeprecatedRegexp.show_deprecation(pattern)
          return DeprecatedRegexp.convert(pattern)
        end

        return PathnamePath.new(pattern) if pattern.is_a?(Pathname)
        return SimplePath.new(pattern) if pattern.is_a?(String)
        Matcher.new(pattern)
      end
    end
  end
end