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 = "%@/"
|
static let forwardSlash = "%@/"
|
||||||
/// A format pattern used to generate relative paths for index files.
|
/// A format pattern used to generate relative paths for index files.
|
||||||
static let index = "%@/%@/index.html"
|
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.
|
/// A format pattern used to generate relative paths that starts with the `/` string.
|
||||||
static let root = "/%@"
|
static let root = "/%@"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ extension String {
|
|||||||
return nil
|
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.
|
/// A model that encapsulates the information related to a resource in a given `DocC` documentation archive.
|
||||||
struct Resource {
|
struct Resource: Equatable {
|
||||||
|
|
||||||
// MARK: Properties
|
// MARK: Properties
|
||||||
|
|
||||||
@@ -38,18 +38,13 @@ struct Resource {
|
|||||||
// MARK: Computed
|
// MARK: Computed
|
||||||
|
|
||||||
/// A relative URI path to a documentation archive the resource belongs to.
|
/// 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)
|
.init(format: .Format.Path.archive, archiveName)
|
||||||
}()
|
}
|
||||||
|
|
||||||
/// A reference name for the documentation archive the resource belongs to.
|
/// A reference name for the documentation archive the resource belongs to.
|
||||||
lazy var archiveReference: String = {
|
var archiveReference: String {
|
||||||
archiveName.lowercased()
|
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
|
import Testing
|
||||||
|
|
||||||
@testable import HummingbirdDocC.Resource
|
@testable import struct HummingbirdDocC.Resource
|
||||||
|
|
||||||
@Suite("Resource", .tags(.model))
|
@Suite("Resource", .tags(.model))
|
||||||
struct ResourceTests {
|
struct ResourceTests {
|
||||||
@@ -35,15 +35,6 @@ struct ResourceTests {
|
|||||||
expects: "somedocument"
|
expects: "somedocument"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
func `full path`() {
|
|
||||||
assertFullPath()(
|
|
||||||
archiveName: "SomeDocument",
|
|
||||||
relativePath: .uriResource,
|
|
||||||
expects: "/somedocument" + .uriResource
|
|
||||||
)
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
@Test("archive path")
|
@Test("archive path")
|
||||||
func archivePath() {
|
func archivePath() {
|
||||||
@@ -60,15 +51,6 @@ struct ResourceTests {
|
|||||||
expects: "somedocument"
|
expects: "somedocument"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("full path")
|
|
||||||
func fullPath() {
|
|
||||||
assertFullPath()(
|
|
||||||
archiveName: "SomeDocument",
|
|
||||||
relativePath: .uriResource,
|
|
||||||
expects: "/somedocument" + .uriResource
|
|
||||||
)
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -88,7 +70,7 @@ private extension ResourceTests {
|
|||||||
expects archivePath: String
|
expects archivePath: String
|
||||||
) {
|
) {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let resource = Resource(
|
var resource = Resource(
|
||||||
archiveName: archiveName,
|
archiveName: archiveName,
|
||||||
relativePath: .empty
|
relativePath: .empty
|
||||||
)
|
)
|
||||||
@@ -109,7 +91,7 @@ private extension ResourceTests {
|
|||||||
expects archiveReference: String
|
expects archiveReference: String
|
||||||
) {
|
) {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let resource = Resource(
|
var resource = Resource(
|
||||||
archiveName: archiveName,
|
archiveName: archiveName,
|
||||||
relativePath: .empty
|
relativePath: .empty
|
||||||
)
|
)
|
||||||
@@ -121,27 +103,4 @@ private extension ResourceTests {
|
|||||||
#expect(result == archiveReference)
|
#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