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:
@@ -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
|
||||
@@ -1,3 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
Message = Struct.new(:timestamp, :username, :text)
|
||||
3
lib/model/message_model.rb
Normal file
3
lib/model/message_model.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
MessageModel = Struct.new(:timestamp, :username, :text)
|
||||
@@ -1,3 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
WikiPage = Struct.new(:id, :path, :title, :description, :created_at, :locale, keyword_init: true)
|
||||
3
lib/model/wiki_page_model.rb
Normal file
3
lib/model/wiki_page_model.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
WikiPageModel = Struct.new(:id, :path, :title, :description, :created_at, :locale, keyword_init: true)
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -1,6 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class OnlineUsers
|
||||
class OnlineUsersRepository
|
||||
def initialize
|
||||
@users = {}
|
||||
@mu = Mutex.new
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user