Class: VCLog::Heuristics::Rule
- Inherits:
-
Object
- Object
- VCLog::Heuristics::Rule
- Defined in:
- lib/vclog/heuristics/rule.rb
Overview
Defines a categorization rule for commits.
Instance Attribute Summary collapse
-
#pattern ⇒ Object
readonly
Message pattern to match for the rule to apply.
Instance Method Summary collapse
-
#call(commit) ⇒ Object
Process the rule.
- #call_commit(commit) ⇒ Object private
- #call_pattern(commit) ⇒ Object private
-
#initialize(pattern = nil) {|An| ... } ⇒ Rule
constructor
Initialize a new log rule.
Constructor Details
#initialize(pattern = nil) {|An| ... } ⇒ Rule
Initialize a new log rule.
23 24 25 26 |
# File 'lib/vclog/heuristics/rule.rb', line 23 def initialize(pattern=nil, &block) @pattern = pattern @block = block end |
Instance Attribute Details
#pattern ⇒ Object (readonly)
Message pattern to match for the rule to apply.
29 30 31 |
# File 'lib/vclog/heuristics/rule.rb', line 29 def pattern @pattern end |
Instance Method Details
#call(commit) ⇒ Object
Process the rule.
38 39 40 41 42 43 44 |
# File 'lib/vclog/heuristics/rule.rb', line 38 def call(commit) if pattern call_pattern(commit) else call_commit(commit) end end |
#call_commit(commit) ⇒ Object (private)
65 66 67 |
# File 'lib/vclog/heuristics/rule.rb', line 65 def call_commit(commit) @block.call(commit) end |
#call_pattern(commit) ⇒ Object (private)
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/vclog/heuristics/rule.rb', line 49 def call_pattern(commit) if matchdata = @pattern.match(commit.) #case @block.arity #when 0 # @block.call #when 1 # @block.call(matchdata) #else @block.call(commit, matchdata) #end else nil end end |