Sha256: 28e544c40e542af7379d2be7e2ac64c71d134692c3f1b0831eeca766720fb217

Contents?: true

Size: 576 Bytes

Versions: 5

Compression:

Stored size: 576 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? }

        private

        attr_reader :text, :delimiter, :minimum

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
git-lint-2.4.0 lib/git/lint/validators/name.rb
git-lint-2.3.3 lib/git/lint/validators/name.rb
git-lint-2.3.2 lib/git/lint/validators/name.rb
git-lint-2.3.1 lib/git/lint/validators/name.rb
git-lint-2.3.0 lib/git/lint/validators/name.rb