Class: Textus::Doctor::Check::ProtocolVersion

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

Overview

Runs as a standalone module (Check::ProtocolVersion.run(root:)) and also as a class-based doctor check (ProtocolVersion.new(store).call).

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Textus::Doctor::Check

#initialize, name_key

Constructor Details

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

Class Method Details

.run(root:) ⇒ Object

Standalone interface: root is the project root (parent of .textus/).



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/textus/doctor/check/protocol_version.rb', line 10

def self.run(root:)
  path = File.join(root, ".textus/manifest.yaml")
  return [] unless File.exist?(path)

  doc = YAML.safe_load_file(path, aliases: false) || {}
  version = doc["version"]
  return [] if version == "textus/3"

  [{
    "code" => "protocol_mismatch",
    "severity" => "error",
    "message" => "Store reports version=#{version.inspect}; this gem expects textus/3.",
    "hint" => "Install textus 0.11.x to run the migrator, then upgrade to this version. See https://github.com/patrick204nqh/textus/blob/main/CHANGELOG.md#0110",
  }]
end

Instance Method Details

#callObject

Doctor check interface: store.root is the .textus/ directory itself, so manifest.yaml lives directly inside it.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/textus/doctor/check/protocol_version.rb', line 28

def call
  path = File.join(store.root, "manifest.yaml")
  return [] unless File.exist?(path)

  doc = YAML.safe_load_file(path, aliases: false) || {}
  version = doc["version"]
  return [] if version == "textus/3"

  [{
    "code" => "protocol_mismatch",
    "level" => "error",
    "subject" => path,
    "message" => "Store reports version=#{version.inspect}; this gem expects textus/3.",
    "fix" => "Install textus 0.11.x to run the migrator, then upgrade to this version. See https://github.com/patrick204nqh/textus/blob/main/CHANGELOG.md#0110",
  }]
end