Class: Git::Lint::Validators::Name

Inherits:
Object
  • Object
show all
Defined in:
lib/git/lint/validators/name.rb

Overview

Validates the format of names.

Constant Summary collapse

DELIMITER =
/\s{1}/
MINIMUM =
2

Instance Method Summary collapse

Constructor Details

#initialize(delimiter: DELIMITER) ⇒ Name

Returns a new instance of Name.



15
16
17
# File 'lib/git/lint/validators/name.rb', line 15

def initialize delimiter: DELIMITER
  @delimiter = delimiter
end

Instance Method Details

#call(content, minimum: MINIMUM) ⇒ Object



19
20
21
22
# File 'lib/git/lint/validators/name.rb', line 19

def call content, minimum: MINIMUM
  parts = String(content).split delimiter
  parts.size >= minimum && parts.all? { |name| !name.blank? }
end