Class: SubjectLengthCheck
- Inherits:
-
CommitCheck
- Object
- CommitCheck
- SubjectLengthCheck
- Defined in:
- lib/wcc/commit_lint/subject_length_check.rb
Class Method Summary collapse
Instance Method Summary collapse
- #fail? ⇒ Boolean
-
#initialize(message, options = {}) ⇒ SubjectLengthCheck
constructor
A new instance of SubjectLengthCheck.
- #message ⇒ Object
Methods inherited from CommitCheck
Constructor Details
#initialize(message, options = {}) ⇒ SubjectLengthCheck
Returns a new instance of SubjectLengthCheck.
8 9 10 11 12 |
# File 'lib/wcc/commit_lint/subject_length_check.rb', line 8 def initialize(, = {}) @subject = [:subject] @max_length = .fetch(:max, 50) @min_length = .fetch(:min, 1) end |
Class Method Details
.type ⇒ Object
4 5 6 |
# File 'lib/wcc/commit_lint/subject_length_check.rb', line 4 def self.type :subject_length end |
Instance Method Details
#fail? ⇒ Boolean
23 24 25 26 |
# File 'lib/wcc/commit_lint/subject_length_check.rb', line 23 def fail? @subject.length > @max_length || @subject.length < @min_length end |
#message ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/wcc/commit_lint/subject_length_check.rb', line 14 def if @subject.length > @max_length "Please limit commit subject line to #{@max_length} characters." else "Please write a commit subject line of at least #{@min_length} "\ 'characters.' end end |