module PaintReport
PaintReport โ Ibis-style IRC cards for !paint replies. Public: help, denial, list_plugins, list_lines, preview, updated, reset, analyse, error_card Depends: IrcReply, TextAlign Tests: test/plugins/paint_test.rb
Constants
- TAG
Public Instance Methods
Source
# File lib/paint_report.rb, line 99 def analyse(result) AnalyseReport.card(result, tag: TAG) end
Source
# File lib/paint_report.rb, line 33 def denial IrcReply.error(tag: TAG, message: "Only channel ops and registered admins can use !paint.") end
Source
# File lib/paint_report.rb, line 103 def error_card(message) IrcReply.error(tag: TAG, message: message) end
Source
# File lib/paint_report.rb, line 17 def help IrcReply.card( tag: TAG, title: "colour overrides", body_lines: [ "!paint list โ plugins with sample output", "!paint list <plugin> โ numbered sample lines", "!paint preview <plugin> โ sample with overrides applied", "!paint reset <plugin> [line] โ clear overrides", "!paint analyse [theme] โ validate theme paint rules against sample lines", "!paint <plugin> <line|range> <pos> <fg[,bg]> [\"snippet\"]" ], footer_parts: ["admin", "channel overrides"] ) end
Source
# File lib/paint_report.rb, line 51 def list_lines(plugin:, lines:) numbered = lines.each_with_index.map do |line, index| plain = TextAlign.plain_length(line) visible = strip_plain(line) "#{index + 1}. #{visible} (#{plain} chars)" end IrcReply.card( tag: TAG, title: plugin, body_lines: numbered, footer_parts: ["plain-text positions", "#{lines.length} lines"] ) end
Source
# File lib/paint_report.rb, line 37 def list_plugins(plugins) body = if plugins.empty? "No registered plugin samples yet." else plugins.join(", ") end IrcReply.card( tag: TAG, title: "registered plugins", body_lines: [body], footer_parts: ["#{plugins.length} plugins"] ) end
Source
# File lib/paint_report.rb, line 65 def preview(plugin:, lines:, override_count:) body = lines.each_with_index.map do |line, index| "#{index + 1}. #{line}" end IrcReply.card( tag: TAG, title: "#{plugin} preview", body_lines: body, footer_parts: ["#{override_count} overrides", "sample output"] ) end
Source
# File lib/paint_report.rb, line 89 def reset(plugin:, line: nil) scope = line ? "line #{line}" : "all lines" IrcReply.card( tag: TAG, title: "#{plugin} reset", body_lines: ["Cleared overrides for #{scope}."], footer_parts: ["preview to verify"] ) end
Source
# File lib/paint_report.rb, line 107 def strip_plain(line) line.to_s.gsub(TextAlign::IRC_CTRL_PATTERN, "") end
Source
# File lib/paint_report.rb, line 77 def updated(plugin:, line:, fg:, bg:, snippet: nil) colour = bg ? "#{fg},#{bg}" : fg.to_s detail = "line #{line} -> #{colour}" detail = "#{detail} ยท snippet #{snippet}" if snippet && !snippet.to_s.strip.empty? IrcReply.card( tag: TAG, title: "#{plugin} updated", body_lines: [detail], footer_parts: ["saved override", "use !paint preview #{plugin}"] ) end