diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-08-03 23:40:30 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-08-03 23:40:30 +0200 |
| commit | 3d3ad4ba90c4d7dea4730ef129f8c9e065f05d6e (patch) | |
| tree | da261f958cca431df16ab8ebc7c22caa81d8db30 /internal | |
| parent | 14c4540d3f06299bf65d74ea864ae7c6c4c33f72 (diff) | |
| download | lectio-3d3ad4ba90c4d7dea4730ef129f8c9e065f05d6e.tar.gz lectio-3d3ad4ba90c4d7dea4730ef129f8c9e065f05d6e.zip | |
liturgy: carry the observed rank on DayInfo
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/liturgy/section.go | 5 | ||||
| -rw-r--r-- | internal/readings/offline.go | 1 | ||||
| -rw-r--r-- | internal/readings/partids_test.go | 30 |
3 files changed, 36 insertions, 0 deletions
diff --git a/internal/liturgy/section.go b/internal/liturgy/section.go index dcca7b5..485a45f 100644 --- a/internal/liturgy/section.go +++ b/internal/liturgy/section.go @@ -33,4 +33,9 @@ type DayInfo struct { // Colour is the normalized liturgical colour: "white", "green", // "violet", "red", "rose", or "" when unknown/unmapped. Colour string + // Rank is the normalized liturgical rank of the observed celebration: + // the Ordinary Form's "ferial", "optional", "memorial", "feast", + // "solemnity", or the 1962 form's "class-1".."class-4", + // "commemoration". Empty when the day carries no rank. + Rank string } diff --git a/internal/readings/offline.go b/internal/readings/offline.go index d0b8942..2f96c14 100644 --- a/internal/readings/offline.go +++ b/internal/readings/offline.go @@ -116,6 +116,7 @@ func dayInfo(cfg config.Config, day calendar.LiturgicalDay) liturgy.DayInfo { return liturgy.DayInfo{ Name: celebrationName(cfg, day.Observed), Colour: string(day.Colour), + Rank: string(day.Observed.Rank), } } diff --git a/internal/readings/partids_test.go b/internal/readings/partids_test.go new file mode 100644 index 0000000..68f5ec0 --- /dev/null +++ b/internal/readings/partids_test.go @@ -0,0 +1,30 @@ +package readings + +import ( + "testing" + + "github.com/lukaszkasprzak/lectio/internal/config" +) + +// The day header must carry the rank, not just name and colour: the app's +// calendar rows and the CLI's day line both display it. +func TestDayInfoCarriesRank(t *testing.T) { + cases := []struct { + date, lect, wantRank string + }{ + // 2026-08-01 is the memorial of St Alphonsus Liguori in the OF. + {"2026-08-01", "new", "memorial"}, + // 2026-12-25 is a solemnity. + {"2026-12-25", "new", "solemnity"}, + } + for _, c := range cases { + cfg := config.Config{UILanguage: "en", Lectionary: c.lect, All: true} + _, info, err := Load(cfg, Options{Date: c.date, All: true}) + if err != nil { + t.Fatalf("%s: load: %v", c.date, err) + } + if info.Rank != c.wantRank { + t.Errorf("%s: rank = %q, want %q", c.date, info.Rank, c.wantRank) + } + } +} |
