Sha256: 0a5416ea6894b43d43cf3c5155dbb9202faa8419bd48c5982ef409fe4db58e8a

Contents?: true

Size: 594 Bytes

Versions: 4

Compression:

Stored size: 594 Bytes

Contents

# frozen_string_literal: true

module Git
  module Lint
    module Validators
      class Capitalization
        DEFAULT_PATTERN = /\A[[:upper:]].*\Z/

        def initialize text, delimiter: Name::DEFAULT_DELIMITER, pattern: DEFAULT_PATTERN
          @text = String text
          @delimiter = delimiter
          @pattern = pattern
        end

        def valid?
          parts.all? { |name| String(name).match? pattern }
        end

        private

        attr_reader :text, :delimiter, :pattern

        def parts
          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/capitalization.rb
git-lint-2.2.0 lib/git/lint/validators/capitalization.rb
git-lint-2.1.0 lib/git/lint/validators/capitalization.rb
git-lint-2.0.0 lib/git/lint/validators/capitalization.rb