Class: FitCommit::Validators::Base

Inherits:
Object
  • Object
show all
Includes:
HasErrors
Defined in:
lib/fit-commit/validators/base.rb

Direct Known Subclasses

Frathouse, LineLength, SummaryPeriod, Tense, Wip

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HasErrors

#add_error, #add_warning, #errors, #merge_errors, #merge_warnings, #warnings

Constructor Details

#initialize(lines, branch_name) ⇒ Base

Returns a new instance of Base.



9
10
11
12
# File 'lib/fit-commit/validators/base.rb', line 9

def initialize(lines, branch_name)
  self.lines = lines
  self.branch_name = branch_name
end

Class Attribute Details

.allObject

Returns the value of attribute all.



16
17
18
# File 'lib/fit-commit/validators/base.rb', line 16

def all
  @all
end

Instance Attribute Details

#branch_nameObject

Returns the value of attribute branch_name.



8
9
10
# File 'lib/fit-commit/validators/base.rb', line 8

def branch_name
  @branch_name
end

#linesObject

Returns the value of attribute lines.



8
9
10
# File 'lib/fit-commit/validators/base.rb', line 8

def lines
  @lines
end

Class Method Details

.inherited(subclass) ⇒ Object



17
18
19
# File 'lib/fit-commit/validators/base.rb', line 17

def inherited(subclass)
  all << subclass
end

Instance Method Details

#validateObject



22
23
24
25
26
# File 'lib/fit-commit/validators/base.rb', line 22

def validate
  lines.each do |line|
    validate_line(line.lineno, line.text, branch_name)
  end
end

#validate_lineObject



28
29
30
# File 'lib/fit-commit/validators/base.rb', line 28

def validate_line(*)
  fail NotImplementedError, "Implement in subclass"
end