Class: CreateRubyGem::Options::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/create_ruby_gem/options/validator.rb

Overview

Validates user-selected options against the compatibility entry for the detected Bundler version.

Checks that: the gem name is valid, every option key is known, every option is supported by this Bundler version, and every value is valid for the option’s type and allowed values.

Constant Summary collapse

GEM_NAME_PATTERN =
/\A[a-zA-Z][a-zA-Z0-9_-]*\z/

Instance Method Summary collapse

Constructor Details

#initialize(compatibility_entry) ⇒ Validator



16
17
18
# File 'lib/create_ruby_gem/options/validator.rb', line 16

def initialize(compatibility_entry)
  @compatibility_entry = compatibility_entry
end

Instance Method Details

#validate!(gem_name:, options:) ⇒ true

Validates the gem name and all options.

Raises:



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/create_ruby_gem/options/validator.rb', line 26

def validate!(gem_name:, options:) # rubocop:disable Naming/PredicateMethod
  validate_gem_name!(gem_name)

  options.each do |key, value|
    validate_option_key!(key)
    validate_supported_option!(key)
    validate_value!(key, value)
    validate_supported_value!(key, value)
  end

  true
end