Skip to content

Commit

Permalink
Rename archive Link property (#422)
Browse files Browse the repository at this point in the history
  • Loading branch information
mickael-menu committed May 14, 2024
1 parent a51c9de commit 8d54648
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 15 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ All notable changes to this project will be documented in this file. Take a look

**Warning:** Features marked as *alpha* may change or be removed in a future release without notice. Use with caution.

<!-- ## [Unreleased] -->
## [Unreleased]

### Changed

#### Shared

* The `Link` property key for archive-based publication assets (e.g. an EPUB/ZIP) is now `https://readium.org/webpub-manifest/properties#archive` instead of `archive`.


## [3.0.0-alpha.1]

Expand Down
5 changes: 1 addition & 4 deletions Sources/Shared/Fetcher/ArchiveFetcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ public final class ArchiveFetcher: Fetcher, Loggable {
private extension ArchiveEntry {
var linkProperties: [String: Any] {
[
// FIXME: Legacy property, should be removed in 3.0.0
"compressedLength": compressedLength as Any,

"archive": [
"https://readium.org/webpub-manifest/properties#archive": [
"entryLength": compressedLength ?? length,
"isEntryCompressed": compressedLength != nil,
] as [String: Any],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ public extension Properties {

/// Provides information about how the resource is stored in the publication archive.
var archive: Archive? {
try? Archive(json: otherProperties["archive"], warnings: self)
try? Archive(json: otherProperties["https://readium.org/webpub-manifest/properties#archive"], warnings: self)
}
}
6 changes: 2 additions & 4 deletions Tests/SharedTests/Fetcher/ArchiveFetcherTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ class ArchiveFetcherTests: XCTestCase {
("META-INF/container.xml", "application/xml", 176, true),
].map { href, type, entryLength, isCompressed in
Link(href: href, type: type, properties: .init([
"compressedLength": (isCompressed ? entryLength : nil) as Any, // legacy
"archive": [
"https://readium.org/webpub-manifest/properties#archive": [
"entryLength": entryLength,
"isEntryCompressed": isCompressed,
] as [String: Any],
Expand Down Expand Up @@ -89,11 +88,10 @@ class ArchiveFetcherTests: XCTestCase {
AssertJSONEqual(
resource.link.properties.json,
[
"archive": [
"https://readium.org/webpub-manifest/properties#archive": [
"entryLength": 595,
"isEntryCompressed": true,
] as [String: Any],
"compressedLength": 595,
] as [String: Any]
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class PropertiesArchiveTests: XCTestCase {
}

func testArchive() {
let sut = Properties(["archive": [
let sut = Properties(["https://readium.org/webpub-manifest/properties#archive": [
"entryLength": 8273,
"isEntryCompressed": true,
] as [String: Any]])
Expand All @@ -23,19 +23,19 @@ class PropertiesArchiveTests: XCTestCase {
}

func testInvalidArchive() {
let sut = Properties(["archive": [
let sut = Properties(["https://readium.org/webpub-manifest/properties#archive": [
"foo": "bar",
]])
XCTAssertNil(sut.archive)
}

func testIncompleteArchive() {
var sut = Properties(["archive": [
var sut = Properties(["https://readium.org/webpub-manifest/properties#archive": [
"entryLength": 8273,
]])
XCTAssertNil(sut.archive)

sut = Properties(["archive": [
sut = Properties(["https://readium.org/webpub-manifest/properties#archive": [
"isEntryCompressed": true,
]])
XCTAssertNil(sut.archive)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ private func makeProperties(layout: EPUBLayout? = nil, archiveEntryLength: UInt6
] as [String: Any]
}
if let archiveEntryLength = archiveEntryLength {
props["archive"] = [
props["https://readium.org/webpub-manifest/properties#archive"] = [
"entryLength": archiveEntryLength as NSNumber,
"isEntryCompressed": true,
]
Expand Down

0 comments on commit 8d54648

Please sign in to comment.