Removed the unnecessary "fullPath" computed property from the Resource model in the library target.
This commit is contained in:
@@ -31,8 +31,6 @@ extension String {
|
||||
static let forwardSlash = "%@/"
|
||||
/// A format pattern used to generate relative paths for index files.
|
||||
static let index = "%@/%@/index.html"
|
||||
/// A format pattern used to generate relative paths for resources.
|
||||
static let resource = "/%@/%@"
|
||||
/// A format pattern used to generate relative paths that starts with the `/` string.
|
||||
static let root = "/%@"
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ extension String {
|
||||
return nil
|
||||
}
|
||||
|
||||
return matches.output.1
|
||||
return matches.output.1 ?? .empty
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
// ===----------------------------------------------------------------------===
|
||||
|
||||
/// A model that encapsulates the information related to a resource in a given `DocC` documentation archive.
|
||||
struct Resource {
|
||||
struct Resource: Equatable {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
@@ -38,18 +38,13 @@ struct Resource {
|
||||
// MARK: Computed
|
||||
|
||||
/// A relative URI path to a documentation archive the resource belongs to.
|
||||
lazy var archivePath: String = {
|
||||
var archivePath: String {
|
||||
.init(format: .Format.Path.archive, archiveName)
|
||||
}()
|
||||
}
|
||||
|
||||
/// A reference name for the documentation archive the resource belongs to.
|
||||
lazy var archiveReference: String = {
|
||||
var archiveReference: String {
|
||||
archiveName.lowercased()
|
||||
}()
|
||||
|
||||
/// A relative URI path to the resource in its documentation archive.
|
||||
lazy var fullPath: String = {
|
||||
.init(format: .Format.Path.archive, archiveName, relativePath)
|
||||
}()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
import Testing
|
||||
|
||||
@testable import HummingbirdDocC.Resource
|
||||
@testable import struct HummingbirdDocC.Resource
|
||||
|
||||
@Suite("Resource", .tags(.model))
|
||||
struct ResourceTests {
|
||||
@@ -35,15 +35,6 @@ struct ResourceTests {
|
||||
expects: "somedocument"
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
func `full path`() {
|
||||
assertFullPath()(
|
||||
archiveName: "SomeDocument",
|
||||
relativePath: .uriResource,
|
||||
expects: "/somedocument" + .uriResource
|
||||
)
|
||||
}
|
||||
#else
|
||||
@Test("archive path")
|
||||
func archivePath() {
|
||||
@@ -60,15 +51,6 @@ struct ResourceTests {
|
||||
expects: "somedocument"
|
||||
)
|
||||
}
|
||||
|
||||
@Test("full path")
|
||||
func fullPath() {
|
||||
assertFullPath()(
|
||||
archiveName: "SomeDocument",
|
||||
relativePath: .uriResource,
|
||||
expects: "/somedocument" + .uriResource
|
||||
)
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -88,7 +70,7 @@ private extension ResourceTests {
|
||||
expects archivePath: String
|
||||
) {
|
||||
// GIVEN
|
||||
let resource = Resource(
|
||||
var resource = Resource(
|
||||
archiveName: archiveName,
|
||||
relativePath: .empty
|
||||
)
|
||||
@@ -109,7 +91,7 @@ private extension ResourceTests {
|
||||
expects archiveReference: String
|
||||
) {
|
||||
// GIVEN
|
||||
let resource = Resource(
|
||||
var resource = Resource(
|
||||
archiveName: archiveName,
|
||||
relativePath: .empty
|
||||
)
|
||||
@@ -120,28 +102,5 @@ private extension ResourceTests {
|
||||
// THEN
|
||||
#expect(result == archiveReference)
|
||||
}
|
||||
|
||||
/// Asserts the `fullPath` computed property of a resource.
|
||||
/// - Parameters:
|
||||
/// - archiveName: A name of the archive the resource belongs to.
|
||||
/// - relativePath: A relative URI path to a resource.
|
||||
/// - fullPath: An expected relative URI path to a resource in its documentation archive.
|
||||
func assertFullPath(
|
||||
archiveName: String,
|
||||
relativePath: String,
|
||||
expects fullPath: String
|
||||
) {
|
||||
// GIVEN
|
||||
let resource = Resource(
|
||||
archiveName: archiveName,
|
||||
relativePath: relativePath
|
||||
)
|
||||
|
||||
// WHEN
|
||||
let result = resource.fullPath
|
||||
|
||||
// THEN
|
||||
#expect(result == fullPath)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user