Class: Expressir::Commands::Validate

Inherits:
Base
  • Object
show all
Defined in:
lib/expressir/commands/validate.rb

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods inherited from Base

#exit_with_error, #initialize, #say

Constructor Details

This class inherits a constructor from Expressir::Commands::Base

Instance Method Details

#run(paths) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/expressir/commands/validate.rb', line 4

def run(paths)
  no_version = []
  no_valid = []

  paths.each do |path|
    x = Pathname.new(path).realpath.relative_path_from(Dir.pwd)
    say "Validating #{x}"
    ret = validate_schema(path)

    if ret.nil?
      no_valid << "Failed to parse: #{x}"
      next
    end

    ret.each do |schema_id|
      no_version << "Missing version string: schema `#{schema_id}` | #{x}"
    end
  end

  print_validation_errors(:failed_to_parse, no_valid)
  print_validation_errors(:missing_version_string, no_version)

  exit 1 unless [no_valid, no_version].all?(&:empty?)

  say "Validation passed for all EXPRESS schemas."
end