Class: Cabriolet::Validator

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

Overview

Archive validation and integrity checking

Constant Summary collapse

LEVEL_QUICK =

Validation levels

:quick
LEVEL_STANDARD =

Basic structure validation

:standard
LEVEL_THOROUGH =

Standard validation with checksums

:thorough

Instance Method Summary collapse

Constructor Details

#initialize(path, level: LEVEL_STANDARD) ⇒ Validator

Full decompression validation



11
12
13
14
15
16
17
# File 'lib/cabriolet/validator.rb', line 11

def initialize(path, level: LEVEL_STANDARD)
  @path = path
  @level = level
  @errors = []
  @warnings = []
  @format = nil
end

Instance Method Details

#validateValidationReport

Validate the archive

Examples:

validator = Cabriolet::Validator.new('archive.cab')
report = validator.validate
puts "Valid: #{report.valid?}"
puts "Errors: #{report.errors}"

Returns:



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/cabriolet/validator.rb', line 28

def validate
  detect_format

  case @level
  when LEVEL_QUICK
    validate_quick
  when LEVEL_STANDARD
    validate_standard
  when LEVEL_THOROUGH
    validate_thorough
  end

  ValidationReport.new(
    valid: @errors.empty?,
    format: @format,
    level: @level,
    errors: @errors,
    warnings: @warnings,
    path: @path,
  )
end