-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from brightdigit/v0.4.0-STRICT-changes
V0.4.0 strict changes
- Loading branch information
Showing
15 changed files
with
340 additions
and
375 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
Sources/SyndiKit/Formats/Feeds/RSS/RSSItem+decodings.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import Foundation | ||
import XMLCoder | ||
|
||
extension RSSItem { | ||
// swiftlint:disable:next function_body_length | ||
public init(from decoder: Decoder) throws { | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
title = try container.decode(String.self, forKey: .title) | ||
link = try container.decodeIfPresent(URL.self, forKey: .link) | ||
description = try container.decodeIfPresent(CData.self, forKey: .description) | ||
guid = try container.decode(EntryID.self, forKey: .guid) | ||
pubDate = try container.decodeDateIfPresentAndValid(forKey: .pubDate) | ||
contentEncoded = try container.decodeIfPresent(CData.self, forKey: .contentEncoded) | ||
categoryTerms = try container.decode([RSSItemCategory].self, forKey: .categoryTerms) | ||
content = try container.decodeIfPresent(String.self, forKey: .content) | ||
itunesTitle = try container.decodeIfPresent(String.self, forKey: .itunesTitle) | ||
itunesEpisode = try container.decodeIfPresent( | ||
iTunesEpisode.self, forKey: .itunesEpisode | ||
) | ||
itunesAuthor = try container.decodeIfPresent(String.self, forKey: .itunesAuthor) | ||
itunesSubtitle = try container.decodeIfPresent(String.self, forKey: .itunesSubtitle) | ||
itunesSummary = try container.decodeIfPresent(CData.self, forKey: .itunesSummary) | ||
itunesExplicit = try container.decodeIfPresent(String.self, forKey: .itunesExplicit) | ||
itunesDuration = try container.decodeIfPresent( | ||
iTunesDuration.self, forKey: .itunesDuration | ||
) | ||
itunesImage = try container.decodeIfPresent(iTunesImage.self, forKey: .itunesImage) | ||
|
||
podcastPeople = try container.decodeIfPresent( | ||
[PodcastPerson].self, | ||
forKey: .podcastPeople | ||
) ?? [] | ||
podcastTranscripts = try container.decodeIfPresent( | ||
[PodcastTranscript].self, | ||
forKey: .podcastTranscripts | ||
) ?? [] | ||
podcastChapters = try container.decodeIfPresent( | ||
PodcastChapters.self, | ||
forKey: .podcastChapters | ||
) | ||
podcastSoundbites = try container.decodeIfPresent( | ||
[PodcastSoundbite].self, | ||
forKey: .podcastSoundbites | ||
) ?? [] | ||
|
||
podcastSeason = try container.decodeIfPresent( | ||
PodcastSeason.self, | ||
forKey: .podcastSeason | ||
) | ||
|
||
enclosure = try container.decodeIfPresent(Enclosure.self, forKey: .enclosure) | ||
creators = try container.decode([String].self, forKey: .creators) | ||
|
||
mediaContent = | ||
try container.decodeIfPresent(AtomMedia.self, forKey: .mediaContent) | ||
mediaThumbnail = | ||
try container.decodeIfPresent(AtomMedia.self, forKey: .mediaThumbnail) | ||
|
||
wpPostID = try container.decodeIfPresent(Int.self, forKey: .wpPostID) | ||
wpPostDate = try container.decodeIfPresent(Date.self, forKey: .wpPostDate) | ||
let wpPostDateGMT = try container.decodeIfPresent( | ||
String.self, forKey: .wpPostDateGMT | ||
) | ||
if let wpPostDateGMT = wpPostDateGMT { | ||
if wpPostDateGMT == "0000-00-00 00:00:00" { | ||
self.wpPostDateGMT = nil | ||
} else { | ||
self.wpPostDateGMT = try container.decode( | ||
Date.self, forKey: .wpPostDateGMT | ||
) | ||
} | ||
} else { | ||
self.wpPostDateGMT = nil | ||
} | ||
|
||
wpModifiedDate = try container.decodeIfPresent( | ||
Date.self, forKey: .wpModifiedDate | ||
) | ||
|
||
let wpModifiedDateGMT = try container.decodeIfPresent( | ||
String.self, forKey: .wpModifiedDateGMT | ||
) | ||
if let wpModifiedDateGMT = wpModifiedDateGMT { | ||
if wpModifiedDateGMT == "0000-00-00 00:00:00" { | ||
self.wpModifiedDateGMT = nil | ||
} else { | ||
self.wpModifiedDateGMT = try container.decode( | ||
Date.self, forKey: .wpModifiedDateGMT | ||
) | ||
} | ||
} else { | ||
self.wpModifiedDateGMT = nil | ||
} | ||
|
||
let wpAttachmentURLCDData = try container.decodeIfPresent( | ||
CData.self, | ||
forKey: .wpAttachmentURL | ||
) | ||
wpAttachmentURL = wpAttachmentURLCDData.map { $0.value }.flatMap(URL.init(string:)) | ||
|
||
wpPostName = try container.decodeIfPresent(CData.self, forKey: .wpPostName) | ||
wpPostType = try container.decodeIfPresent(CData.self, forKey: .wpPostType) | ||
wpPostMeta = try container.decodeIfPresent( | ||
[WordPressElements.PostMeta].self, | ||
forKey: .wpPostMeta | ||
) ?? [] | ||
wpCommentStatus = try container.decodeIfPresent(CData.self, forKey: .wpCommentStatus) | ||
wpPingStatus = try container.decodeIfPresent(CData.self, forKey: .wpPingStatus) | ||
wpStatus = try container.decodeIfPresent(CData.self, forKey: .wpStatus) | ||
wpPostParent = try container.decodeIfPresent(Int.self, forKey: .wpPostParent) | ||
wpMenuOrder = try container.decodeIfPresent(Int.self, forKey: .wpMenuOrder) | ||
wpIsSticky = try container.decodeIfPresent(Int.self, forKey: .wpIsSticky) | ||
wpPostPassword = try container.decodeIfPresent( | ||
CData.self, forKey: .wpPostPassword | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import Foundation | ||
import XMLCoder | ||
|
||
extension RSSItem { | ||
// swiftlint:disable:next function_body_length | ||
public init( | ||
title: String, | ||
link: URL, | ||
description: String?, | ||
guid: EntryID, | ||
pubDate: Date? = nil, | ||
contentEncoded: String? = nil, | ||
categoryTerms: [RSSItemCategory] = [], | ||
content: String? = nil, | ||
itunesTitle: String? = nil, | ||
itunesEpisode: Int? = nil, | ||
itunesAuthor: String? = nil, | ||
itunesSubtitle: String? = nil, | ||
itunesSummary: CData? = nil, | ||
itunesExplicit: String? = nil, | ||
itunesDuration: TimeInterval? = nil, | ||
itunesImage: iTunesImage? = nil, | ||
podcastPeople: [PodcastPerson] = [], | ||
podcastTranscripts: [PodcastTranscript] = [], | ||
podcastChapters: PodcastChapters? = nil, | ||
podcastSoundbites: [PodcastSoundbite] = [], | ||
podcastSeason: PodcastSeason? = nil, | ||
enclosure: Enclosure? = nil, | ||
creators: [String] = [], | ||
wpCommentStatus: String? = nil, | ||
wpPingStatus: String? = nil, | ||
wpStatus: String? = nil, | ||
wpPostParent: Int? = nil, | ||
wpMenuOrder: Int? = nil, | ||
wpIsSticky: Int? = nil, | ||
wpPostPassword: String? = nil, | ||
wpPostID: Int? = nil, | ||
wpPostDate: Date? = nil, | ||
wpPostDateGMT: Date? = nil, | ||
wpModifiedDate: Date? = nil, | ||
wpModifiedDateGMT: Date? = nil, | ||
wpPostName: String? = nil, | ||
wpPostType: String? = nil, | ||
wpPostMeta: [WordPressElements.PostMeta] = [], | ||
wpAttachmentURL: URL? = nil, | ||
mediaContent: AtomMedia? = nil, | ||
mediaThumbnail: AtomMedia? = nil | ||
) { | ||
self.title = title | ||
self.link = link | ||
self.description = description.map(CData.init) | ||
self.guid = guid | ||
self.pubDate = pubDate | ||
self.contentEncoded = contentEncoded.map(CData.init) | ||
self.categoryTerms = categoryTerms | ||
self.content = content | ||
self.itunesTitle = itunesTitle | ||
self.itunesEpisode = itunesEpisode.map(iTunesEpisode.init) | ||
self.itunesAuthor = itunesAuthor | ||
self.itunesSubtitle = itunesSubtitle | ||
self.itunesSummary = itunesSummary | ||
self.itunesExplicit = itunesExplicit | ||
self.itunesDuration = itunesDuration.map(iTunesDuration.init) | ||
self.itunesImage = itunesImage | ||
self.podcastPeople = podcastPeople | ||
self.podcastTranscripts = podcastTranscripts | ||
self.podcastChapters = podcastChapters | ||
self.podcastSoundbites = podcastSoundbites | ||
self.podcastSeason = podcastSeason | ||
self.enclosure = enclosure | ||
self.creators = creators | ||
self.wpCommentStatus = wpCommentStatus.map(CData.init) | ||
self.wpPingStatus = wpPingStatus.map(CData.init) | ||
self.wpStatus = wpStatus.map(CData.init) | ||
self.wpPostParent = wpPostParent | ||
self.wpMenuOrder = wpMenuOrder | ||
self.wpIsSticky = wpIsSticky | ||
self.wpPostPassword = wpPostPassword.map(CData.init) | ||
self.wpPostID = wpPostID | ||
self.wpPostDate = wpPostDate | ||
self.wpPostDateGMT = wpPostDateGMT | ||
self.wpModifiedDate = wpModifiedDate | ||
self.wpModifiedDateGMT = wpModifiedDateGMT | ||
self.wpPostName = wpPostName.map(CData.init) | ||
self.wpPostType = wpPostType.map(CData.init) | ||
self.wpPostMeta = wpPostMeta | ||
self.wpAttachmentURL = wpAttachmentURL | ||
self.mediaContent = mediaContent | ||
self.mediaThumbnail = mediaThumbnail | ||
} | ||
} |
Oops, something went wrong.