Class: Mxrb::Integrity::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/mxrb/integrity/validator.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Validator

Returns a new instance of Validator.



12
13
14
15
# File 'lib/mxrb/integrity/validator.rb', line 12

def initialize(path)
  @path = path
  @progress = Progress::NullTask.instance
end

Instance Method Details

#validateObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/mxrb/integrity/validator.rb', line 17

def validate
  Progress.with("Validating #{File.basename(@path)}") do |progress|
    @progress = progress
    @errors = []
    @warnings = []
    @mpr = IO::MprFile.open(@path, readonly: true)
    validate_tables
    progress.advance(detail: "MPR tables")
    validate_units
    validate_v2_files
    progress.advance(detail: "v2 contents")
    Result.new(errors: @errors, warnings: @warnings)
  end
rescue Error => e
  Result.new(errors: [e.message], warnings: @warnings || [])
ensure
  @progress = Progress::NullTask.instance
  @mpr&.close
end