Module: Legion::Extensions::Detect::Formatters::MarkdownPr
- Defined in:
- lib/legion/extensions/detect/formatters/markdown_pr.rb
Class Method Summary collapse
- .collect_installed(detections) ⇒ Object
- .collect_missing(detections) ⇒ Object
- .format(detections) ⇒ Object
Class Method Details
.collect_installed(detections) ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/legion/extensions/detect/formatters/markdown_pr.rb', line 48 def collect_installed(detections) detections.flat_map do |d| d[:extensions].filter_map do |ext| next unless d[:installed][ext] { name: d[:name], extension: ext } end end end |
.collect_missing(detections) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/legion/extensions/detect/formatters/markdown_pr.rb', line 38 def collect_missing(detections) detections.flat_map do |d| d[:extensions].filter_map do |ext| next if d[:installed][ext] { name: d[:name], extension: ext, signals: d[:matched_signals] } end end end |
.format(detections) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/legion/extensions/detect/formatters/markdown_pr.rb', line 10 def format(detections) missing = collect_missing(detections) installed = collect_installed(detections) lines = ["## Legion Detect Findings\n"] if missing.any? lines << "### Missing Extensions (#{missing.size})\n" missing.each do |m| lines << "- **#{m[:name]}**: `#{m[:extension]}` not installed" lines << " Detected by: #{m[:signals].join(', ')}" lines << " Install: `gem install #{m[:extension]}`\n" end end if installed.any? lines << "### Installed (#{installed.size})\n" installed.each do |i| lines << "- #{i[:name]}: `#{i[:extension]}` :white_check_mark:" end end lines << "No extensions detected.\n" if missing.empty? && installed.empty? lines << "\n---\n*Generated by legion-detect v#{VERSION}*" lines.join("\n") end |