module WhatsnewFeed
Constants
- DISPLAY_LIMIT
- PLUGIN
- STYLE_TITLE
Public Instance Methods
Source
# File lib/whatsnew_feed.rb, line 58 def command_reply(store: RabbotDb) entries = recent_entries(WhatsnewStore.load_entries(store: store)) format_reply(entries) || format_empty_reply end
Source
# File lib/whatsnew_feed.rb, line 18 def entries_since(entries, since:) cutoff = since.is_a?(Time) ? since : RabbotDb.parse_time(since) return [] unless cutoff Array(entries).select do |entry| recorded = RabbotDb.parse_time(entry["recorded_at"]) recorded && recorded > cutoff end end
Source
# File lib/whatsnew_feed.rb, line 48 def format_empty_reply(title: "Recent plugins") IrcReply.card( tag: "WHATSNEW", title: title, body_lines: ["No plugin updates recorded yet."], footer_parts: ["0 items", "plugin updates"], heading_style: STYLE_TITLE ) end
Source
# File lib/whatsnew_feed.rb, line 28 def format_line(entry) plugin = entry["plugin"].to_s summary = entry["summary"].to_s.strip label = entry["kind"].to_s == "enhance" ? "#{plugin} (enhanced)" : plugin "#{label} — #{summary}" end
Source
# File lib/whatsnew_feed.rb, line 35 def format_reply(entries, title: "Recent plugins") rows = Array(entries) return nil if rows.empty? IrcReply.card( tag: "WHATSNEW", title: title, body_lines: rows.map { |entry| format_line(entry) }, footer_parts: ["#{rows.length} items", "plugin updates"], heading_style: STYLE_TITLE ) end
Source
# File lib/whatsnew_feed.rb, line 14 def recent_entries(entries, limit: DISPLAY_LIMIT) Array(entries).first(limit) end