Class: Glossarist::GcrValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/glossarist/gcr_validator.rb

Instance Method Summary collapse

Instance Method Details

#validate(zip_path) ⇒ Object

rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/glossarist/gcr_validator.rb', line 7

def validate(zip_path) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
  result = ValidationResult.new

  unless File.exist?(zip_path)
    result.add_error("File not found: #{zip_path}")
    return result
  end

  begin
    Zip::File.open(zip_path) do |zip_file|
      validate_zip_contents(zip_file, result)
    end
  rescue StandardError => e
    result.add_error("Failed to read ZIP: #{e.message}")
  end

  result
end