Class: Rosette::Core::Validators::RepoValidator

Inherits:
Validator
  • Object
show all
Defined in:
lib/rosette/core/validators/repo_validator.rb

Overview

Validates a repo by making sure it has been configured.

Examples:

v = RepoValidator.new
v.valid?('my_repo', nil, config)   # => true
v.valid?('bad_repo', nil, config)  # => false
v.messages  # => ["Unable to find repo 'bad_repo'."]

Instance Attribute Summary

Attributes inherited from Validator

#options

Instance Method Summary collapse

Methods inherited from Validator

#initialize, #messages

Constructor Details

This class inherits a constructor from Rosette::Core::Validators::Validator

Instance Method Details

#valid?(repo_name, _, configuration) ⇒ Boolean

Returns true if the repo is valid, false otherwise

Parameters:

  • repo_name (String)

    The repo to validate.

  • _ (String)

    (not used)

  • configuration (Configurator)

    The Rosette configuration to use.

Returns:

  • (Boolean)

21
22
23
24
25
26
27
28
# File 'lib/rosette/core/validators/repo_validator.rb', line 21

def valid?(repo_name, _, configuration)
  if !configuration.get_repo(repo_name)
    messages << "Unable to find repo '#{repo_name}'."
    false
  else
    true
  end
end