Class: GitComitter::PatternMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/git-comitter/commit.rb

Instance Method Summary collapse

Constructor Details

#initialize(patterns, &block) ⇒ PatternMatcher

Returns a new instance of PatternMatcher.



3
4
5
6
# File 'lib/git-comitter/commit.rb', line 3

def initialize(patterns, &block)
  @patterns = patterns
  @commit_property = block
end

Instance Method Details

#match(commits) ⇒ Object



8
9
10
11
# File 'lib/git-comitter/commit.rb', line 8

def match(commits)
  messages = commits.map{|c| @commit_property.call c}
  return messages.all? {|message| @patterns.any?{ |pattern| message =~ pattern } }
end