Class: Fp::Commands::Matrix
Overview
fp matrix --project
Constant Summary collapse
- KNOWN_FLAGS =
{ project: :string, csv: :boolean }.freeze
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Fp::Commands::Base
Instance Method Details
#run(args) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/fp/commands/matrix.rb', line 13 def run(args) opts, = parse_flags(args, KNOWN_FLAGS) require_flag(opts, :project) workspace_id = resolve_workspace_id(opts[:project]) # Get workspace for surfaces ws_result = client.get_project(workspace_id) unless ws_result[:ok] output.error(ws_result[:error], status: ws_result[:status]) exit 1 end workspace = ws_result[:data]['workspace'] surfaces = workspace['available_surfaces'] || [] # Get active requirements req_result = client.list_requirements(workspace_id: workspace_id) unless req_result[:ok] output.error(req_result[:error], status: req_result[:status]) exit 1 end requirements = (req_result[:data]['requirements'] || []).select { |r| r['status'] == 'active' } if requirements.empty? output.success({ matrix: [], surfaces: surfaces }) do puts 'No active requirements. The matrix is empty.' end return end # Build matrix data # Columns: SLUG, TITLE, then one column per surface headers = %w[SLUG TITLE] + surfaces rows = requirements.map do |req| required = req['required_surfaces'] || [] # Evidence status per surface (placeholder until Evidence API exists) surface_cells = surfaces.map do |s| if required.include?(s) '⬜' # Required but no evidence yet else '-' # Not required end end [req['slug'], truncate(req['title'], 30)] + surface_cells end if opts[:csv] output.csv(headers, rows) else output.success({ requirements: requirements, surfaces: surfaces, project: opts[:project] }) do puts "Parity Matrix: #{opts[:project]}" puts output.table(headers, rows) puts puts 'Legend: ✅ = passing, ⬜ = required (no evidence), - = not required' end end end |