Class: Textus::Doctor::Check::IntakeRegistration

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

Constant Summary collapse

BUILTIN =
%i[json csv markdown-links ical-events rss].freeze

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



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
# File 'lib/textus/doctor/check/intake_registration.rb', line 7

def call
  declared = collect_declared_handlers
  registered = steps.names(:fetch).to_set

  out = (declared - registered).map do |name|
    {
      "code" => "intake.handler_missing",
      "level" => "error",
      "subject" => name.to_s,
      "message" => "manifest references intake handler '#{name}' but no fetch step for '#{name}' is registered",
      "fix" => "create .textus/steps/fetch/#{name}.rb with `class #{name.to_s.split(/[-_]/).map(&:capitalize).join}Fetch < Textus::Step::Fetch`",
    }
  end

  (registered - declared - BUILTIN.to_set).each do |name|
    out << {
      "code" => "intake.handler_orphan",
      "level" => "warning",
      "subject" => name.to_s,
      "message" => "fetch step '#{name}' is registered but no manifest entry references it",
      "fix" => "remove the unused step, or add an entry with `intake.handler: #{name}`",
    }
  end

  out
end