module Loom::Pattern::ExpandingReference::Matcher::GlobMatcher

Constants

MATCH_P

Public Class Methods

handles_pattern?(p) click to toggle source
# File lib/loom/pattern/expanding_reference.rb, line 71
def self.handles_pattern?(p)
  p.match? MATCH_P
end

Public Instance Methods

match?(your_pattern) click to toggle source
# File lib/loom/pattern/expanding_reference.rb, line 75
def match?(your_pattern)
  # TODO: This can be made RE2 compliant later.
  unless GlobMatcher.handles_pattern?(@my_slug)
    raise 'WTF? invalid pattern, must end in "*": %s' % @my_slug
  end

  prefix = @my_slug.to_s.gsub(MATCH_P, "")
  Loom.log.debug2(self) { "GlobMatcher+match?+ #{@my_slug} #{your_pattern}, prefix: #{prefix}"}
  your_pattern.to_s.start_with? prefix
end