Move COLORS and c() to BBS::Color in rubbs
include BBS::Color at top level — c() available everywhere including instance_eval blocks and OutputBuilder. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
14
bbs.rb
14
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"
|
||||
|
||||
Reference in New Issue
Block a user