| 1 | | import Foundation |
| 2 | | |
| 3 | | /// Every file of a run that has no coverage: the page, `totals.json` and the stylesheet. |
| 4 | | /// Values only; writing them is the command's job. |
| 5 | | public struct UnavailableSite: Sendable { |
| 6 | | public let files: [CoverageSite.File] |
| 7 | | |
| 8 | | /// - Parameter date: when the run was built; recorded in `totals.json`. |
| 9 | | public init( |
| 10 | | title: String, reason: String, commit: String?, subject: String?, date: Date |
| 11 | 2 | ) throws { |
| 12 | 2 | let page = UnavailablePage(title: title, reason: reason, commit: commit, subject: subject) |
| 13 | 2 | let totals = RunTotals( |
| 14 | 2 | unavailableBecause: reason, commit: commit, subject: subject, date: date) |
| 15 | 2 | files = [ |
| 16 | 2 | CoverageSite.File(path: UnavailablePage.sitePath, contents: page.html), |
| 17 | 2 | CoverageSite.File( |
| 18 | 2 | path: RunTotals.fileName, |
| 19 | 2 | contents: String(decoding: try totals.json(), as: UTF8.self)), |
| 20 | 2 | CoverageSite.File(path: SiteStylesheet.fileName, contents: SiteStylesheet.contents), |
| 21 | 2 | ] |
| 22 | 2 | } |
| 23 | | } |