Add Model/Repository postfix to all class and file names

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-30 09:40:14 +02:00
parent 6856b073f6
commit 9ab2e09b3f
10 changed files with 31 additions and 31 deletions

18
bbs.rb
View File

@@ -2,15 +2,15 @@
require 'bbs'
require 'time'
require_relative 'lib/repository/online_users'
require_relative 'lib/repository/message_board'
require_relative 'lib/repository/wiki'
require_relative 'lib/repository/catalog'
require_relative 'lib/repository/online_users_repository'
require_relative 'lib/repository/message_board_repository'
require_relative 'lib/repository/wiki_repository'
require_relative 'lib/repository/catalog_repository'
ONLINE = OnlineUsers.new
MESSAGES = MessageBoard.new(ENV.fetch('MESSAGES_PATH', 'data/messages.dat'))
WIKI = WikiClient.new(token: ENV['WEBAPP_WIKIJS_TOKEN'])
CATALOG = CatalogClient.new
ONLINE = OnlineUsersRepository.new
MESSAGES = MessageBoardRepository.new(ENV.fetch('MESSAGES_PATH', 'data/messages.dat'))
WIKI = WikiRepository.new(token: ENV['WEBAPP_WIKIJS_TOKEN'])
CATALOG = CatalogRepository.new
module C
RESET = "\e[0m"
@@ -147,7 +147,7 @@ BBS.configure do |c|
end
out << "\r\n #{C::GRAY}#{'─' * 66}#{C::RESET}\r\n"
out << " #{C::GRAY}#{CatalogClient::GAMES_URL}#{C::RESET}\r\n\r\n"
out << " #{C::GRAY}#{CatalogRepository::GAMES_URL}#{C::RESET}\r\n\r\n"
out
end
wait_enter

View File

@@ -1,6 +1,6 @@
# frozen_string_literal: true
class Game
class GameModel
attr_reader :title, :platform, :author, :desc,
:play_path, :download_path, :source_path, :docs_path,
:release_count

View File

@@ -1,3 +0,0 @@
# frozen_string_literal: true
Message = Struct.new(:timestamp, :username, :text)

View File

@@ -0,0 +1,3 @@
# frozen_string_literal: true
MessageModel = Struct.new(:timestamp, :username, :text)

View File

@@ -1,3 +0,0 @@
# frozen_string_literal: true
WikiPage = Struct.new(:id, :path, :title, :description, :created_at, :locale, keyword_init: true)

View File

@@ -0,0 +1,3 @@
# frozen_string_literal: true
WikiPageModel = Struct.new(:id, :path, :title, :description, :created_at, :locale, keyword_init: true)

View File

@@ -3,9 +3,9 @@
require 'net/http'
require 'json'
require 'uri'
require_relative '../model/game'
require_relative '../model/game_model'
class CatalogClient
class CatalogRepository
API_URL = 'https://games.teletype.hu/api/software'
GAMES_URL = 'https://games.teletype.hu'
@@ -17,9 +17,9 @@ class CatalogClient
http.read_timeout = 12
data = JSON.parse(http.get(uri.path).body)
entries = data.is_a?(Hash) ? (data['softwares'] || []) : data
entries.filter_map { |e| Game.new(e) if e.is_a?(Hash) }
entries.filter_map { |e| GameModel.new(e) if e.is_a?(Hash) }
rescue => e
warn "Catalog fetch error: #{e}"
warn "CatalogRepository fetch error: #{e}"
[]
end

View File

@@ -3,9 +3,9 @@
require 'csv'
require 'time'
require 'fileutils'
require_relative '../model/message'
require_relative '../model/message_model'
class MessageBoard
class MessageBoardRepository
def initialize(path)
@path = path
@messages = []
@@ -14,7 +14,7 @@ class MessageBoard
end
def append(username, text)
msg = Message.new(Time.now.strftime('%m-%d %H:%M'), username, text)
msg = MessageModel.new(Time.now.strftime('%m-%d %H:%M'), username, text)
@mu.synchronize do
@messages << msg
FileUtils.mkdir_p(File.dirname(@path))
@@ -35,8 +35,8 @@ class MessageBoard
def load_csv
return unless File.exist?(@path)
CSV.foreach(@path) { |row| @messages << Message.new(*row) }
CSV.foreach(@path) { |row| @messages << MessageModel.new(*row) }
rescue => e
warn "MessageBoard load error: #{e}"
warn "MessageBoardRepository load error: #{e}"
end
end

View File

@@ -1,6 +1,6 @@
# frozen_string_literal: true
class OnlineUsers
class OnlineUsersRepository
def initialize
@users = {}
@mu = Mutex.new

View File

@@ -3,9 +3,9 @@
require 'net/http'
require 'json'
require 'uri'
require_relative '../model/wiki_page'
require_relative '../model/wiki_page_model'
class WikiClient
class WikiRepository
BASE_URL = 'https://wiki.teletype.hu'
def initialize(token: nil)
@@ -19,7 +19,7 @@ class WikiClient
}}}
GQL
(graphql(query).dig('data', 'pages', 'list') || []).map do |p|
WikiPage.new(
WikiPageModel.new(
id: p['id'],
path: p['path'],
title: p['title'],
@@ -29,7 +29,7 @@ class WikiClient
)
end
rescue => e
warn "Wiki list error: #{e}"
warn "WikiRepository list error: #{e}"
[]
end
@@ -37,7 +37,7 @@ class WikiClient
query = "{ pages { single(id: #{page_id}) { content } } }"
graphql(query).dig('data', 'pages', 'single', 'content') || ''
rescue => e
warn "Wiki content error: #{e}"
warn "WikiRepository content error: #{e}"
''
end