Class: Rigor::CLI::PluginsRenderer
- Inherits:
-
Object
- Object
- Rigor::CLI::PluginsRenderer
- Defined in:
- lib/rigor/cli/plugins_renderer.rb
Overview
Renderer for rigor plugins. Produces a human-readable text table and a JSON representation from the same row
shape (the Hash documented on Rigor::CLI::PluginsCommand#loaded_row).
The two formats carry the same content; JSON is meant for tooling (SKILLs, CI, editor integrations) while text is for interactive inspection. Rows are printed in the order the loader resolved them.
Instance Method Summary collapse
-
#capabilities_json ⇒ Object
ADR-37 § "Machine-readable capability catalogue" — the focused per-plugin extension-protocol dump.
- #capabilities_text ⇒ Object
-
#initialize(rows:, configuration_path:, inflection: nil) ⇒ PluginsRenderer
constructor
inflection:(ADR-90) is nil, or{required_by: [ids], available: Boolean}— the activation-timePlugin::Inflectorprobe result when a loaded plugin consumes the shared inflection helper. - #json ⇒ Object
- #text ⇒ Object
Constructor Details
#initialize(rows:, configuration_path:, inflection: nil) ⇒ PluginsRenderer
inflection: (ADR-90) is nil, or {required_by: [ids], available: Boolean} — the activation-time
Plugin::Inflector probe result when a loaded plugin consumes the shared inflection helper.
15 16 17 18 19 |
# File 'lib/rigor/cli/plugins_renderer.rb', line 15 def initialize(rows:, configuration_path:, inflection: nil) @rows = rows @configuration_path = configuration_path @inflection = inflection end |
Instance Method Details
#capabilities_json ⇒ Object
ADR-37 § "Machine-readable capability catalogue" — the focused per-plugin extension-protocol dump. Only loaded plugins appear (a plugin that failed to load contributes no capabilities), and each carries only the gate values an agent enumerates to learn what the plugin does: node-rule node types, dynamic-return receivers, type-specifier methods, and produced / consumed facts.
54 55 56 57 58 59 60 61 |
# File 'lib/rigor/cli/plugins_renderer.rb', line 54 def capabilities_json JSON.pretty_generate( { "configuration" => @configuration_path, "capabilities" => loaded_rows.map { |row| capabilities_json_for(row) } } ) end |
#capabilities_text ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/rigor/cli/plugins_renderer.rb', line 63 def capabilities_text lines = ["Plugin capability catalogue (ADR-37 narrow extension protocols)", ""] loaded = loaded_rows if loaded.empty? lines << " (no plugins loaded)" else loaded.each_with_index do |row, index| lines.concat(capability_lines(row)) lines << "" unless index == loaded.size - 1 end end lines.join("\n") end |
#json ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rigor/cli/plugins_renderer.rb', line 35 def json payload = { "configuration" => @configuration_path, "plugins" => @rows.map { |row| row_json(row) }, "summary" => summary } unless @inflection.nil? payload["inflection"] = { "required_by" => @inflection.fetch(:required_by), "available" => @inflection.fetch(:available) } end JSON.pretty_generate(payload) end |
#text ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rigor/cli/plugins_renderer.rb', line 21 def text lines = [] lines << header lines << "" @rows.each_with_index do |row, index| lines.concat(row_lines(row)) lines << "" unless index == @rows.size - 1 end lines << "" lines << lines.concat(inflection_warning_lines) lines.join("\n") end |