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:) ⇒ PluginsRenderer
constructor
rubocop:disable Metrics/ClassLength.
- #json ⇒ Object
- #text ⇒ Object
Constructor Details
#initialize(rows:, configuration_path:) ⇒ PluginsRenderer
rubocop:disable Metrics/ClassLength
13 14 15 16 |
# File 'lib/rigor/cli/plugins_renderer.rb', line 13 def initialize(rows:, configuration_path:) @rows = rows @configuration_path = configuration_path 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.
45 46 47 48 49 50 51 52 |
# File 'lib/rigor/cli/plugins_renderer.rb', line 45 def capabilities_json JSON.pretty_generate( { "configuration" => @configuration_path, "capabilities" => loaded_rows.map { |row| capabilities_json_for(row) } } ) end |
#capabilities_text ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/rigor/cli/plugins_renderer.rb', line 54 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
31 32 33 34 35 36 37 38 39 |
# File 'lib/rigor/cli/plugins_renderer.rb', line 31 def json JSON.pretty_generate( { "configuration" => @configuration_path, "plugins" => @rows.map { |row| row_json(row) }, "summary" => summary } ) end |
#text ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rigor/cli/plugins_renderer.rb', line 18 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.join("\n") end |