module CachyReport
Constants
- FOOTER
- TAG
Public Instance Methods
Source
# File lib/cachy_report.rb, line 75 def build_fetch_error(query) SearchReport.fetch_error_card( tag: TAG, query: query, fallback_title: "package search", error_lines: [ "CachyOS package search unavailable right now.", "Try: #{CachySearch.browse_url(query)}" ], footer_parts: FOOTER ) end
Source
# File lib/cachy_report.rb, line 38 def build_report(query:, total:, items:) if items.empty? return SearchReport.empty_report( tag: TAG, query: query, total: 0, empty_lines: [ "No CachyOS repo matches for that keyword.", "Browse: #{CachySearch.browse_url(query)}" ], footer_parts: FOOTER ) end extra = total - items.length body_lines = items.each_with_index.map { |item, index| format_item_line(index + 1, item) } body_lines << "... #{TextUtil.format_count(extra)} more in CachyOS repos" if extra.positive? SearchReport.results_report( tag: TAG, query: query, total: total, body_lines: body_lines, footer_parts: FOOTER, comma_count: true ) end
Source
# File lib/cachy_report.rb, line 66 def build_usage SearchReport.usage_card( tag: TAG, title: "package search", usage_message: CachySearch.usage_message, footer_parts: FOOTER ) end
Source
# File lib/cachy_report.rb, line 26 def format_item_line(index, item) meta = [item[:version], format_repo_arch(item)] meta << CachySearch.truncate_text(item[:description]) SearchReport.list_item_line( index: index, title: item[:name], detail_parts: meta.reject(&:empty?), url: item[:url] ) end
Source
# File lib/cachy_report.rb, line 18 def format_repo_arch(item) repo = item[:repo].to_s.strip arch = item[:arch].to_s.strip return "" if repo.empty? || arch.empty? "#{repo}/#{arch}" end