Class: Textus::Doctor::Check::RawAssetPaths

Inherits:
Textus::Doctor::Check show all
Defined in:
lib/textus/doctor/check/raw_asset_paths.rb

Instance Method Summary collapse

Methods inherited from Textus::Doctor::Check

#initialize, name_key

Constructor Details

This class inherits a constructor from Textus::Doctor::Check

Instance Method Details

#callObject



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
30
31
32
33
# File 'lib/textus/doctor/check/raw_asset_paths.rb', line 5

def call
  raw_lane = manifest.policy.lanes_of_kind(:raw).first
  return [] unless raw_lane

  issues = []
  manifest.resolver.enumerate.each do |row|
    next unless row[:key].start_with?("raw.")
    next unless row[:path] && File.exist?(row[:path])

    raw_content = load_content(row[:path])
    next unless raw_content.is_a?(Hash)

    asset = raw_content["asset"]
    next unless asset.is_a?(String) && !asset.empty?

    asset_path = find_asset_path(asset)
    next if File.exist?(asset_path)

    issues << {
      "code" => "raw_asset.missing_file",
      "level" => "error",
      "subject" => row[:key],
      "message" => "raw entry '#{row[:key]}' references asset '#{asset}' " \
                   "which does not exist at #{asset_path}",
      "fix" => "re-ingest the asset: textus key-delete #{row[:key]}, then textus ingest",
    }
  end
  issues
end