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
17 18 19 20 |
# File 'lib/rigor/cli/plugins_renderer.rb', line 17 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.
51 52 53 54 55 56 57 58 |
# File 'lib/rigor/cli/plugins_renderer.rb', line 51 def capabilities_json JSON.pretty_generate( { "configuration" => @configuration_path, "capabilities" => loaded_rows.map { |row| capabilities_json_for(row) } } ) end |
#capabilities_text ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/rigor/cli/plugins_renderer.rb', line 60 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 |
# File 'lib/rigor/cli/plugins_renderer.rb', line 35 def json JSON.pretty_generate( { "configuration" => @configuration_path, "plugins" => @rows.map { |row| row_json(row) }, "summary" => summary } ) end |
#text ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rigor/cli/plugins_renderer.rb', line 22 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 |