A platform is named once: WarpEngine::Platform

The list of platforms lived on `PlatformLink::SUPPORTED_PLATFORMS` — a model
about links to a platform's website — and was copied around it four times in
the admin (`%w[tic80 ebitengine love c64 godot bevy phaser]`), spelled out in
three apipie descriptions, and turned into a class name by string
interpolation in three services:

    "WarpEngine::Platforms::#{platform.camelize}::Service".constantize

Seven places that had to agree, and nothing that made them.

`WarpEngine::Platform` is now that one place. `Platform.names` is the list,
`Platform.find!("godot")` answers with a value object that knows its `label`,
its `expected_kinds` and its updater `service`, and the constantize is gone —
the registry holds the reference. `PublishService` and `BuildsService` ask it,
the admin selects read `Platform.names`, and
`PlatformLink::SUPPORTED_PLATFORMS` stays as an alias of `Platform::NAMES` so
a host pinned to 0.7 keeps working.

`Software` also defends its own value sets now. It validated neither `status`
nor `platform`, so a mistyped platform only surfaced later, at publish time,
as "Unsupported platform" — after the row existed. And `status` had three
different answers depending on where you looked: the admin offered
development/demo/released/archived, the API documentation claimed
"active, inactive", and the database holds the first four. `Software::STATUSES`
is the list, the inclusion validations enforce both, and the documentation
names the values the database actually has.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-23 09:00:55 +02:00
co-authored by Claude Opus 5
parent 19d142ef64
commit f1ad80ed0c
10 changed files with 86 additions and 33 deletions
+11 -10
View File
@@ -38,18 +38,19 @@ ActiveAdmin.register WarpEngine::Software, as: "Software" do
filter :name
filter :title
filter :author
filter :platform, as: :select, collection: %w[tic80 ebitengine love c64 godot bevy phaser]
filter :status, as: :select, collection: %w[development demo released archived]
filter :platform, as: :select, collection: WarpEngine::Platform.names
filter :status, as: :select, collection: WarpEngine::Software::STATUSES
filter :highlighted
sidebar "Quick Links", only: :show, priority: 0 do
site_url = ENV.fetch("SITE_URL", "https://teletypegames.org")
catalog_url = "#{site_url}/catalog/#{resource.name}"
if WarpEngine.config.site_url.present?
catalog_url = "#{WarpEngine.config.site_url.chomp('/')}/catalog/#{resource.name}"
div style: "margin-bottom:8px;" do
a href: catalog_url, target: "_blank", style: "display:inline-flex;align-items:center;gap:6px;font-weight:bold;color:#5850ec;" do
span "🌐", style: "font-size:16px;"
text_node "View on site"
div style: "margin-bottom:8px;" do
a href: catalog_url, target: "_blank", style: "display:inline-flex;align-items:center;gap:6px;font-weight:bold;color:#5850ec;" do
span "🌐", style: "font-size:16px;"
text_node "View on site"
end
end
end
@@ -103,8 +104,8 @@ ActiveAdmin.register WarpEngine::Software, as: "Software" do
f.input :name
f.input :title
f.input :author
f.input :platform, as: :select, collection: %w[tic80 ebitengine love c64 godot bevy phaser]
f.input :status, as: :select, collection: %w[development demo released archived]
f.input :platform, as: :select, collection: WarpEngine::Platform.names
f.input :status, as: :select, collection: WarpEngine::Software::STATUSES
f.input :highlighted
f.input :license
f.input :desc, as: :text, input_html: { rows: 4 }