Sha256: 967c3359646e17379597577d9257f0a8eda794edbcc7e082cbf4025a32b36459

Contents?: true

Size: 615 Bytes

Versions: 4

Compression:

Stored size: 615 Bytes

Contents

# frozen_string_literal: true

module Git
  module Lint
    module Validators
      class Name
        DEFAULT_DELIMITER = /\s{1}/
        DEFAULT_MINIMUM = 2

        def initialize text, delimiter: DEFAULT_DELIMITER, minimum: DEFAULT_MINIMUM
          @text = text
          @delimiter = delimiter
          @minimum = minimum
        end

        def valid?
          parts.size >= minimum && parts.all? { |name| !String(name).empty? }
        end

        private

        attr_reader :text, :delimiter, :minimum

        def parts
          String(text).split delimiter
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
git-lint-2.2.1 lib/git/lint/validators/name.rb
git-lint-2.2.0 lib/git/lint/validators/name.rb
git-lint-2.1.0 lib/git/lint/validators/name.rb
git-lint-2.0.0 lib/git/lint/validators/name.rb