Give the config module a home to load from #45
Labels
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Blocks
Depends on
#47 Honor CASINO_CONFIG_DIR and CASINO_DATA_DIR
rosa/casino
#46 Open the casino against a home
rosa/casino
#49 Reject a currency code that isn't one
rosa/casino
#51 Record how the casino finds its files
rosa/casino
#44 Put the config's settings behind accessors
rosa/casino
Reference
rosa/casino#45
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What to build
Nothing can point the casino at a directory other than the player's real home.
The config module asks
ProjectDirswhere it lives whenever it wants to know,which means loading a config, creating one, or resolving a save path all write
into the actual
~/.config/casino— so none of it has ever been under test.The tests that exist cover deserialization and stop there.
Give the module its locations instead of letting it find them. Two values, in
two stages, because resolution genuinely has two: you need the config directory
to find the config, and then the config itself to finish settling where the save
and stats files are.
Home— the two directories the casino was given. Built either from apair of directories outright, which is the seam a test uses, or by asking the
system where a user's files go. This follows the shape ADR 0002 already
established for engines: a seam constructor taking the thing that would
otherwise be reached for, and a convenient constructor that stays a thin
wrapper over it. It is also the only place in the crate that names
ProjectDirs.Files— the path of every file the casino writes, settled from aHomeand a
Config. It keeps itsHome, so anything that needs both the files andthe directories they sit in takes one argument.
The save and stats paths become optional overrides rather than settings that are
always present. Today they are serialized with defaults computed from the global
data directory at deserialize time, so a fresh install writes absolute paths into
the player's own config file as though they had chosen them, and
Config'sDefaultcannot be computed without touching the filesystem. As overrides, anabsent value means the standard place, a present one wins, and the default
becomes pure.
Configgains a single door — load against aHome, creating the file with thehouse defaults when it isn't there. That replaces the three that exist now, one
of which welds loading to first-run creation behind a name that says neither.
The casino keeps the signature it has and reaches for a
Homeinternally; theticket that hands it one properly comes next.
Acceptance criteria
the real home untouched
data directory
player who moved their save does not lose it
paths
Config'sDefaulttouches no filesystem and asks nothing of the systemProjectDirsis named in exactly one place in the cratecan find the setting and edit it
error rather than panicking past the
Resultit is already insave and stats paths explicitly
stats paths into itself
Blocked by