class FitCommit::Validators::Base
Attributes
all[RW]
branch_name[RW]
config[RW]
Public Class Methods
inherited(subclass)
click to toggle source
# File lib/fit_commit/validators/base.rb, line 17 def inherited(subclass) all << subclass end
new(branch_name, config)
click to toggle source
# File lib/fit_commit/validators/base.rb, line 9 def initialize(branch_name, config) self.branch_name = branch_name self.config = config end
Public Instance Methods
enabled?()
click to toggle source
# File lib/fit_commit/validators/base.rb, line 30 def enabled? enabled_val = config.fetch("Enabled") if enabled_val.is_a?(Array) enabled_val.any? { |pattern| matches_branch?(pattern) } else enabled_val end end
matches_branch?(pattern)
click to toggle source
# File lib/fit_commit/validators/base.rb, line 39 def matches_branch?(pattern) if pattern.is_a?(Regexp) pattern =~ branch_name else pattern == branch_name end end
validate(lines)
click to toggle source
# File lib/fit_commit/validators/base.rb, line 22 def validate(lines) lines.each { |line| validate_line(line.lineno, line.text) } end
validate_line(*)
click to toggle source
# File lib/fit_commit/validators/base.rb, line 26 def validate_line(*) fail NotImplementedError, "Implement in subclass" end