File: simple_path.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 (23 lines) | stat: -rw-r--r-- 499 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
module Guard
  class Watcher
    class Pattern
      class SimplePath
        def initialize(string_or_pathname)
          @path = normalize(string_or_pathname)
        end

        def match(string_or_pathname)
          cleaned = normalize(string_or_pathname)
          return nil unless @path == cleaned
          [cleaned]
        end

        protected

        def normalize(string_or_pathname)
          Pathname.new(string_or_pathname).cleanpath.to_s
        end
      end
    end
  end
end