From 3a90dd541ec13defcf276f8e1639b44c6addbf25 Mon Sep 17 00:00:00 2001 From: Zsolt Tasnadi Date: Thu, 30 Apr 2026 10:34:47 +0200 Subject: [PATCH] Move COLORS and c() to BBS::Color in rubbs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit include BBS::Color at top level — c() available everywhere including instance_eval blocks and OutputBuilder. Co-Authored-By: Claude Sonnet 4.6 --- bbs.rb | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/bbs.rb b/bbs.rb index aa5b141..91146fb 100644 --- a/bbs.rb +++ b/bbs.rb @@ -7,21 +7,13 @@ require_relative 'lib/repository/message_board_repository' require_relative 'lib/repository/wiki_repository' require_relative 'lib/repository/catalog_repository' +include BBS::Color + ONLINE = OnlineUsersRepository.new MESSAGES = MessageBoardRepository.new(ENV.fetch('MESSAGES_PATH', 'data/messages.dat')) WIKI = WikiRepository.new(token: ENV['WEBAPP_WIKIJS_TOKEN']) CATALOG = CatalogRepository.new -COLORS = { - reset: "\e[0m", gray: "\e[0;37m", yellow: "\e[0;33m", - white: "\e[1;37m", blue: "\e[0;34m", cyan: "\e[0;36m", - green: "\e[1;32m", magenta: "\e[0;35m", red: "\e[1;31m" -}.freeze - -def c(color, text) - "#{COLORS.fetch(color)}#{text}#{COLORS[:reset]}" -end - class OutputBuilder def initialize = (@buf = +''; @badges = []) def to_s = (flush_badges; @buf) @@ -52,8 +44,6 @@ class OutputBuilder private - def c(color, text) = "#{COLORS.fetch(color)}#{text}#{COLORS[:reset]}" - def flush_badges return if @badges.empty? @buf << " #{@badges.join(' ')}\r\n"