Sha256: 7952da366969d271c595c469da25d0821f52303123694a3453acc98323e4cd57

Contents?: true

Size: 601 Bytes

Versions: 7

Compression:

Stored size: 601 Bytes

Contents

# frozen_string_literal: true

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

        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

7 entries across 7 versions & 1 rubygems

Version Path
git-lint-1.4.0 lib/git/lint/validators/capitalization.rb
git-lint-1.3.0 lib/git/lint/validators/capitalization.rb
git-lint-1.2.0 lib/git/lint/validators/capitalization.rb
git-lint-1.1.1 lib/git/lint/validators/capitalization.rb
git-lint-1.1.0 lib/git/lint/validators/capitalization.rb
git-lint-1.0.1 lib/git/lint/validators/capitalization.rb
git-lint-1.0.0 lib/git/lint/validators/capitalization.rb