Class: Indexmap::Validator

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

Instance Method Summary collapse

Constructor Details

#initialize(configuration: Indexmap.configuration, filename: nil) ⇒ Validator

Returns a new instance of Validator.



10
11
12
13
# File 'lib/indexmap/validator.rb', line 10

def initialize(configuration: Indexmap.configuration, filename: nil)
  @configuration = configuration
  @filename = filename
end

Instance Method Details

#validate!Object

Raises:



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/indexmap/validator.rb', line 15

def validate!
  sitemap_filename = filename || configuration.index_filename
  raise ValidationError, "Missing sitemap file: #{sitemap_filename}" unless storage.exist?(sitemap_filename)

  validate_sitemap_file!(sitemap_filename)
  entries = Parser.new(source: sitemap_filename, storage: storage, index_filename: configuration.index_filename).entries
  validate_presence!(entries)
  validate_duplicates!(entries)
  validate_parameterized_urls!(entries)
  validate_fragment_urls!(entries)
  validate_absolute_http_urls!(entries)
  validate_same_host_urls!(entries)
  validate_lastmods!(entries)
  true
end