Module: OnestopIdRegistryValidator

Defined in:
lib/onestop_id_registry_validator.rb,
lib/onestop_id_registry_validator/version.rb,
lib/onestop_id_registry_validator/internal_validation.rb

Constant Summary collapse

VERSION =
'0.0.4'
ENTITIES_TO_VALIDATE =
[:feeds, :operators]

Class Method Summary collapse

Class Method Details

.validate_allObject



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/onestop_id_registry_validator/internal_validation.rb', line 36

def self.validate_all
  errors = {}
  ENTITIES_TO_VALIDATE.each do |entity_to_validate|
    OnestopIdClient::Registry.json_files_for_entity(entity_to_validate.to_s).each do |file_path|
      file = File.open(file_path, 'r')
      file_errors = validate(entity_to_validate, file.read)
      errors[File.basename(file)] = file_errors if file_errors && file_errors.length > 0
    end
  end
  all_valid = (errors.length == 0)
  return all_valid, errors
end

.validate_return_errors_and_exitObject



49
50
51
52
53
54
55
56
57
# File 'lib/onestop_id_registry_validator/internal_validation.rb', line 49

def self.validate_return_errors_and_exit
  all_valid, errors = validate_all
  if errors.length > 0
    puts errors.inspect
  else
    puts "All JSON feed definition files validated."
    Process.exit(0)
  end
end