module Quaker::TagMatcher
Public Class Methods
match(tags, patterns)
click to toggle source
# File lib/quaker/tag_matcher.rb, line 3 def self.match tags, patterns return true if patterns.nil? || patterns.empty? return false if tags.nil? || tags.empty? patterns.any? {|pattern| tags.any? {|tag| pattern_matches_string?(tag, pattern)} } end
pattern_matches_string?(s, pattern)
click to toggle source
# File lib/quaker/tag_matcher.rb, line 12 def self.pattern_matches_string? s, pattern s == pattern || wildcard_matches?(s, pattern) end
wildcard_matches?(s, pattern)
click to toggle source
# File lib/quaker/tag_matcher.rb, line 16 def self.wildcard_matches? s, pattern return false unless pattern.include?('*') escaped = Regexp.escape(pattern).gsub('\*','.*?') regex = Regexp.new "^#{escaped}$", Regexp::IGNORECASE !!(s =~ regex) end