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:
@@ -12,6 +12,11 @@ Repository: `https://git.teletypegames.org/engines/warp_engine`
|
||||
- **Catalog domain**: `Software`, `Release`, `ReleaseAsset`, `ExternalLink`,
|
||||
`PlatformLink`, `SoftwareImage`, `Download` models with soft-delete
|
||||
semantics and download statistics.
|
||||
- **Platform registry**: `WarpEngine::Platform` is the one place a platform is
|
||||
named. `Platform.names` lists them, `Platform.find!("godot")` answers with a
|
||||
value object that knows its `label`, its `expected_kinds` and its updater
|
||||
`service`. Reference it instead of writing a platform list of your own —
|
||||
`PlatformLink::SUPPORTED_PLATFORMS` is kept as an alias of `Platform::NAMES`.
|
||||
- **CI-callable updater**: your build pipeline uploads artifacts over HTTP
|
||||
and calls one endpoint — WarpEngine extracts archives, parses metadata
|
||||
and upserts the catalog records. Supported platforms out of the
|
||||
@@ -203,6 +208,10 @@ Rails.application.config.to_prepare do
|
||||
# Where CI drops build artifacts
|
||||
c.file_container_path = ENV.fetch("FILE_CONTAINER_PATH", "/softwares")
|
||||
|
||||
# Where the site this catalog belongs to lives. The admin links a software
|
||||
# to its public page from here; left nil, the link is left out.
|
||||
c.site_url = ENV["SITE_URL"]
|
||||
|
||||
# Your image model (see "Images" below). "Image" is the default.
|
||||
# c.image_class_name = "Media::Picture"
|
||||
# c.image_adapter = MyImageLibrary.new
|
||||
|
||||
Reference in New Issue
Block a user