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 = store.registry.rpc_names(:intake).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 Textus.intake(:#{name}) is registered",
      "fix" => "create .textus/hooks/#{name}.rb with `Textus.intake(:#{name}) { ... }`",
    }
  end

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

  out
end