Class: Rigor::CLI::PluginsRenderer

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(rows:, configuration_path:) ⇒ PluginsRenderer

Returns a new instance of PluginsRenderer.



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

#jsonObject



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

#textObject



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 << footer
  lines.join("\n")
end