diff --git a/analysis_options.yaml b/analysis_options.yaml index 2c9d809..d74c8fe 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -33,3 +33,4 @@ linter: - slash_for_doc_comments - type_init_formals - unnecessary_new + - prefer_single_quotes diff --git a/example/main.dart b/example/main.dart index a722833..7a4500c 100644 --- a/example/main.dart +++ b/example/main.dart @@ -6,12 +6,12 @@ void main() async { // RSS feed var response = await client - .get("https://developer.apple.com/news/releases/rss/releases.rss"); + .get('https://developer.apple.com/news/releases/rss/releases.rss'); var channel = RssFeed.parse(response.body); print(channel); // Atom feed - response = await client.get("https://www.theverge.com/rss/index.xml"); + response = await client.get('https://www.theverge.com/rss/index.xml'); var feed = AtomFeed.parse(response.body); print(feed); diff --git a/lib/domain/atom_category.dart b/lib/domain/atom_category.dart index 22c6a97..acd5b58 100644 --- a/lib/domain/atom_category.dart +++ b/lib/domain/atom_category.dart @@ -8,9 +8,9 @@ class AtomCategory { AtomCategory(this.term, this.scheme, this.label); factory AtomCategory.parse(XmlElement element) { - var term = element.getAttribute("term"); - var scheme = element.getAttribute("scheme"); - var label = element.getAttribute("label"); + var term = element.getAttribute('term'); + var scheme = element.getAttribute('scheme'); + var label = element.getAttribute('label'); return AtomCategory(term, scheme, label); } } diff --git a/lib/domain/atom_feed.dart b/lib/domain/atom_feed.dart index 06d1b2c..8a4f75e 100644 --- a/lib/domain/atom_feed.dart +++ b/lib/domain/atom_feed.dart @@ -43,36 +43,36 @@ class AtomFeed { var document = XmlDocument.parse(xmlString); XmlElement feedElement; try { - feedElement = document.findElements("feed").first; + feedElement = document.findElements('feed').first; } on StateError { - throw ArgumentError("feed not found"); + throw ArgumentError('feed not found'); } return AtomFeed( - id: findElementOrNull(feedElement, "id")?.text, - title: findElementOrNull(feedElement, "title")?.text, - updated: parseDateTime(findElementOrNull(feedElement, "updated")?.text), - items: feedElement.findElements("entry").map((element) { + id: findElementOrNull(feedElement, 'id')?.text, + title: findElementOrNull(feedElement, 'title')?.text, + updated: parseDateTime(findElementOrNull(feedElement, 'updated')?.text), + items: feedElement.findElements('entry').map((element) { return AtomItem.parse(element); }).toList(), - links: feedElement.findElements("link").map((element) { + links: feedElement.findElements('link').map((element) { return AtomLink.parse(element); }).toList(), - authors: feedElement.findElements("author").map((element) { + authors: feedElement.findElements('author').map((element) { return AtomPerson.parse(element); }).toList(), - contributors: feedElement.findElements("contributor").map((element) { + contributors: feedElement.findElements('contributor').map((element) { return AtomPerson.parse(element); }).toList(), - categories: feedElement.findElements("category").map((element) { + categories: feedElement.findElements('category').map((element) { return AtomCategory.parse(element); }).toList(), generator: - AtomGenerator.parse(findElementOrNull(feedElement, "generator")), - icon: findElementOrNull(feedElement, "icon")?.text, - logo: findElementOrNull(feedElement, "logo")?.text, - rights: findElementOrNull(feedElement, "rights")?.text, - subtitle: findElementOrNull(feedElement, "subtitle")?.text, + AtomGenerator.parse(findElementOrNull(feedElement, 'generator')), + icon: findElementOrNull(feedElement, 'icon')?.text, + logo: findElementOrNull(feedElement, 'logo')?.text, + rights: findElementOrNull(feedElement, 'rights')?.text, + subtitle: findElementOrNull(feedElement, 'subtitle')?.text, ); } } diff --git a/lib/domain/atom_generator.dart b/lib/domain/atom_generator.dart index 14eb70d..b3a0b5f 100644 --- a/lib/domain/atom_generator.dart +++ b/lib/domain/atom_generator.dart @@ -11,8 +11,8 @@ class AtomGenerator { if (element == null) { return null; } - var uri = element.getAttribute("uri"); - var version = element.getAttribute("version"); + var uri = element.getAttribute('uri'); + var version = element.getAttribute('version'); var value = element.text; return AtomGenerator(uri, version, value); } diff --git a/lib/domain/atom_item.dart b/lib/domain/atom_item.dart index f04181f..2b93ccc 100644 --- a/lib/domain/atom_item.dart +++ b/lib/domain/atom_item.dart @@ -41,26 +41,26 @@ class AtomItem { factory AtomItem.parse(XmlElement element) { return AtomItem( - id: findElementOrNull(element, "id")?.text, - title: findElementOrNull(element, "title")?.text, - updated: parseDateTime(findElementOrNull(element, "updated")?.text), - authors: element.findElements("author").map((element) { + id: findElementOrNull(element, 'id')?.text, + title: findElementOrNull(element, 'title')?.text, + updated: parseDateTime(findElementOrNull(element, 'updated')?.text), + authors: element.findElements('author').map((element) { return AtomPerson.parse(element); }).toList(), - links: element.findElements("link").map((element) { + links: element.findElements('link').map((element) { return AtomLink.parse(element); }).toList(), - categories: element.findElements("category").map((element) { + categories: element.findElements('category').map((element) { return AtomCategory.parse(element); }).toList(), - contributors: element.findElements("contributor").map((element) { + contributors: element.findElements('contributor').map((element) { return AtomPerson.parse(element); }).toList(), - source: AtomSource.parse(findElementOrNull(element, "source")), - published: findElementOrNull(element, "published")?.text, - content: findElementOrNull(element, "content")?.text, - summary: findElementOrNull(element, "summary")?.text, - rights: findElementOrNull(element, "rights")?.text, + source: AtomSource.parse(findElementOrNull(element, 'source')), + published: findElementOrNull(element, 'published')?.text, + content: findElementOrNull(element, 'content')?.text, + summary: findElementOrNull(element, 'summary')?.text, + rights: findElementOrNull(element, 'rights')?.text, media: Media.parse(element), ); } diff --git a/lib/domain/atom_link.dart b/lib/domain/atom_link.dart index 3b570f2..9b68ac2 100644 --- a/lib/domain/atom_link.dart +++ b/lib/domain/atom_link.dart @@ -18,14 +18,14 @@ class AtomLink { ); factory AtomLink.parse(XmlElement element) { - var href = element.getAttribute("href"); - var rel = element.getAttribute("rel"); - var type = element.getAttribute("type"); - var title = element.getAttribute("title"); - var hreflang = element.getAttribute("hreflang"); + var href = element.getAttribute('href'); + var rel = element.getAttribute('rel'); + var type = element.getAttribute('type'); + var title = element.getAttribute('title'); + var hreflang = element.getAttribute('hreflang'); var length = 0; - if (element.getAttribute("length") != null) { - length = int.parse(element.getAttribute("length")); + if (element.getAttribute('length') != null) { + length = int.parse(element.getAttribute('length')); } return AtomLink(href, rel, type, hreflang, title, length); } diff --git a/lib/domain/atom_person.dart b/lib/domain/atom_person.dart index c68fe45..1d84e6c 100644 --- a/lib/domain/atom_person.dart +++ b/lib/domain/atom_person.dart @@ -9,9 +9,9 @@ class AtomPerson { AtomPerson(this.name, this.uri, this.email); factory AtomPerson.parse(XmlElement element) { - var name = findElementOrNull(element, "name")?.text; - var uri = findElementOrNull(element, "uri")?.text; - var email = findElementOrNull(element, "email")?.text; + var name = findElementOrNull(element, 'name')?.text; + var uri = findElementOrNull(element, 'uri')?.text; + var email = findElementOrNull(element, 'email')?.text; return AtomPerson(name, uri, email); } } diff --git a/lib/domain/atom_source.dart b/lib/domain/atom_source.dart index d632d5a..9f1b34b 100644 --- a/lib/domain/atom_source.dart +++ b/lib/domain/atom_source.dart @@ -12,9 +12,9 @@ class AtomSource { if (element == null) { return null; } - var id = findElementOrNull(element, "id")?.text; - var title = findElementOrNull(element, "title")?.text; - var updated = findElementOrNull(element, "updated")?.text; + var id = findElementOrNull(element, 'id')?.text; + var title = findElementOrNull(element, 'title')?.text; + var updated = findElementOrNull(element, 'updated')?.text; return AtomSource(id, title, updated); } diff --git a/lib/domain/dublin_core/dublin_core.dart b/lib/domain/dublin_core/dublin_core.dart index 53a496c..b36c004 100644 --- a/lib/domain/dublin_core/dublin_core.dart +++ b/lib/domain/dublin_core/dublin_core.dart @@ -46,23 +46,23 @@ class DublinCore { return null; } return DublinCore( - title: findElementOrNull(element, "dc:title")?.text, - description: findElementOrNull(element, "dc:description")?.text, - creator: findElementOrNull(element, "dc:creator")?.text, - subject: findElementOrNull(element, "dc:subject")?.text, - publisher: findElementOrNull(element, "dc:publisher")?.text, - contributor: findElementOrNull(element, "dc:contributor")?.text, - date: parseDateTime(findElementOrNull(element, "dc:date")?.text), - created: parseDateTime(findElementOrNull(element, "dc:created")?.text), - modified: parseDateTime(findElementOrNull(element, "dc:modified")?.text), - type: findElementOrNull(element, "dc:type")?.text, - format: findElementOrNull(element, "dc:format")?.text, - identifier: findElementOrNull(element, "dc:identifier")?.text, - source: findElementOrNull(element, "dc:source")?.text, - language: findElementOrNull(element, "dc:language")?.text, - relation: findElementOrNull(element, "dc:relation")?.text, - coverage: findElementOrNull(element, "dc:coverage")?.text, - rights: findElementOrNull(element, "dc:rights")?.text, + title: findElementOrNull(element, 'dc:title')?.text, + description: findElementOrNull(element, 'dc:description')?.text, + creator: findElementOrNull(element, 'dc:creator')?.text, + subject: findElementOrNull(element, 'dc:subject')?.text, + publisher: findElementOrNull(element, 'dc:publisher')?.text, + contributor: findElementOrNull(element, 'dc:contributor')?.text, + date: parseDateTime(findElementOrNull(element, 'dc:date')?.text), + created: parseDateTime(findElementOrNull(element, 'dc:created')?.text), + modified: parseDateTime(findElementOrNull(element, 'dc:modified')?.text), + type: findElementOrNull(element, 'dc:type')?.text, + format: findElementOrNull(element, 'dc:format')?.text, + identifier: findElementOrNull(element, 'dc:identifier')?.text, + source: findElementOrNull(element, 'dc:source')?.text, + language: findElementOrNull(element, 'dc:language')?.text, + relation: findElementOrNull(element, 'dc:relation')?.text, + coverage: findElementOrNull(element, 'dc:coverage')?.text, + rights: findElementOrNull(element, 'dc:rights')?.text, ); } } diff --git a/lib/domain/media/category.dart b/lib/domain/media/category.dart index 9029738..967e0a2 100644 --- a/lib/domain/media/category.dart +++ b/lib/domain/media/category.dart @@ -16,8 +16,8 @@ class Category { return null; } return Category( - scheme: element.getAttribute("scheme"), - label: element.getAttribute("label"), + scheme: element.getAttribute('scheme'), + label: element.getAttribute('label'), value: element.text, ); } diff --git a/lib/domain/media/community.dart b/lib/domain/media/community.dart index 6f1c685..fcbbf8a 100644 --- a/lib/domain/media/community.dart +++ b/lib/domain/media/community.dart @@ -21,13 +21,13 @@ class Community { } return Community( starRating: StarRating.parse( - findElementOrNull(element, "media:starRating"), + findElementOrNull(element, 'media:starRating'), ), statistics: Statistics.parse( - findElementOrNull(element, "media:statistics"), + findElementOrNull(element, 'media:statistics'), ), tags: Tags.parse( - findElementOrNull(element, "media:tags"), + findElementOrNull(element, 'media:tags'), ), ); } diff --git a/lib/domain/media/content.dart b/lib/domain/media/content.dart index e580e5f..061119c 100644 --- a/lib/domain/media/content.dart +++ b/lib/domain/media/content.dart @@ -35,22 +35,22 @@ class Content { factory Content.parse(XmlElement element) { return Content( - url: element.getAttribute("url"), - type: element.getAttribute("type"), - fileSize: int.tryParse(element.getAttribute("fileSize") ?? "0"), - medium: element.getAttribute("medium"), - isDefault: element.getAttribute("isDefault") == "true", - expression: element.getAttribute("expression"), - bitrate: int.tryParse(element.getAttribute("bitrate") ?? "0"), - framerate: double.tryParse(element.getAttribute("framerate") ?? "0"), + url: element.getAttribute('url'), + type: element.getAttribute('type'), + fileSize: int.tryParse(element.getAttribute('fileSize') ?? '0'), + medium: element.getAttribute('medium'), + isDefault: element.getAttribute('isDefault') == 'true', + expression: element.getAttribute('expression'), + bitrate: int.tryParse(element.getAttribute('bitrate') ?? '0'), + framerate: double.tryParse(element.getAttribute('framerate') ?? '0'), samplingrate: double.tryParse( - element.getAttribute("samplingrate") ?? "0", + element.getAttribute('samplingrate') ?? '0', ), - channels: int.tryParse(element.getAttribute("channels") ?? "0"), - duration: int.tryParse(element.getAttribute("duration") ?? "0"), - height: int.tryParse(element.getAttribute("height") ?? "0"), - width: int.tryParse(element.getAttribute("width") ?? "0"), - lang: element.getAttribute("lang"), + channels: int.tryParse(element.getAttribute('channels') ?? '0'), + duration: int.tryParse(element.getAttribute('duration') ?? '0'), + height: int.tryParse(element.getAttribute('height') ?? '0'), + width: int.tryParse(element.getAttribute('width') ?? '0'), + lang: element.getAttribute('lang'), ); } } diff --git a/lib/domain/media/copyright.dart b/lib/domain/media/copyright.dart index f4b5b8b..e40c4c7 100644 --- a/lib/domain/media/copyright.dart +++ b/lib/domain/media/copyright.dart @@ -14,7 +14,7 @@ class Copyright { return null; } return Copyright( - url: element.getAttribute("url"), + url: element.getAttribute('url'), value: element.text, ); } diff --git a/lib/domain/media/credit.dart b/lib/domain/media/credit.dart index 212dac1..3f0838b 100644 --- a/lib/domain/media/credit.dart +++ b/lib/domain/media/credit.dart @@ -13,8 +13,8 @@ class Credit { factory Credit.parse(XmlElement element) { return Credit( - role: element.getAttribute("role"), - scheme: element.getAttribute("scheme"), + role: element.getAttribute('role'), + scheme: element.getAttribute('scheme'), value: element.text, ); } diff --git a/lib/domain/media/description.dart b/lib/domain/media/description.dart index 17bb1cb..29866d0 100644 --- a/lib/domain/media/description.dart +++ b/lib/domain/media/description.dart @@ -14,7 +14,7 @@ class Description { return null; } return Description( - type: element.getAttribute("type"), + type: element.getAttribute('type'), value: element.text, ); } diff --git a/lib/domain/media/embed.dart b/lib/domain/media/embed.dart index 6fc84ea..81555be 100644 --- a/lib/domain/media/embed.dart +++ b/lib/domain/media/embed.dart @@ -19,10 +19,10 @@ class Embed { return null; } return Embed( - url: element.getAttribute("url"), - width: int.tryParse(element.getAttribute("width") ?? "0"), - height: int.tryParse(element.getAttribute("height") ?? "0"), - params: element.findElements("media:param").map((e) { + url: element.getAttribute('url'), + width: int.tryParse(element.getAttribute('width') ?? '0'), + height: int.tryParse(element.getAttribute('height') ?? '0'), + params: element.findElements('media:param').map((e) { return Param.parse(e); }).toList(), ); diff --git a/lib/domain/media/group.dart b/lib/domain/media/group.dart index 2be5efd..7f656a9 100644 --- a/lib/domain/media/group.dart +++ b/lib/domain/media/group.dart @@ -23,17 +23,17 @@ class Group { return null; } return Group( - contents: element.findElements("media:content").map((e) { + contents: element.findElements('media:content').map((e) { return Content.parse(e); }).toList(), - credits: element.findElements("media:credit").map((e) { + credits: element.findElements('media:credit').map((e) { return Credit.parse(e); }).toList(), category: Category.parse( - findElementOrNull(element, "media:category"), + findElementOrNull(element, 'media:category'), ), rating: Rating.parse( - findElementOrNull(element, "media:rating"), + findElementOrNull(element, 'media:rating'), ), ); } diff --git a/lib/domain/media/hash.dart b/lib/domain/media/hash.dart index 01ad1c3..bfcbd72 100644 --- a/lib/domain/media/hash.dart +++ b/lib/domain/media/hash.dart @@ -14,7 +14,7 @@ class Hash { return null; } return Hash( - algo: element.getAttribute("algo"), + algo: element.getAttribute('algo'), value: element.text, ); } diff --git a/lib/domain/media/license.dart b/lib/domain/media/license.dart index 75db98e..e3990db 100644 --- a/lib/domain/media/license.dart +++ b/lib/domain/media/license.dart @@ -16,8 +16,8 @@ class License { return null; } return License( - type: element.getAttribute("type"), - href: element.getAttribute("href"), + type: element.getAttribute('type'), + href: element.getAttribute('href'), value: element.text, ); } diff --git a/lib/domain/media/media.dart b/lib/domain/media/media.dart index fc37773..c5655a2 100644 --- a/lib/domain/media/media.dart +++ b/lib/domain/media/media.dart @@ -80,86 +80,86 @@ class Media { factory Media.parse(XmlElement element) { return Media( group: Group.parse( - findElementOrNull(element, "media:group"), + findElementOrNull(element, 'media:group'), ), - contents: element.findElements("media:content").map((e) { + contents: element.findElements('media:content').map((e) { return Content.parse(e); }).toList(), - credits: element.findElements("media:credit").map((e) { + credits: element.findElements('media:credit').map((e) { return Credit.parse(e); }).toList(), category: Category.parse( - findElementOrNull(element, "media:category"), + findElementOrNull(element, 'media:category'), ), rating: Rating.parse( - findElementOrNull(element, "media:rating"), + findElementOrNull(element, 'media:rating'), ), title: Title.parse( - findElementOrNull(element, "media:title"), + findElementOrNull(element, 'media:title'), ), description: Description.parse( - findElementOrNull(element, "media:description"), + findElementOrNull(element, 'media:description'), ), - keywords: findElementOrNull(element, "media:keywords")?.text, - thumbnails: element.findElements("media:thumbnail").map((e) { + keywords: findElementOrNull(element, 'media:keywords')?.text, + thumbnails: element.findElements('media:thumbnail').map((e) { return Thumbnail.parse(e); }).toList(), hash: Hash.parse( - findElementOrNull(element, "media:hash"), + findElementOrNull(element, 'media:hash'), ), player: Player.parse( - findElementOrNull(element, "media:player"), + findElementOrNull(element, 'media:player'), ), copyright: Copyright.parse( - findElementOrNull(element, "media:copyright"), + findElementOrNull(element, 'media:copyright'), ), text: Text.parse( - findElementOrNull(element, "media:text"), + findElementOrNull(element, 'media:text'), ), restriction: Restriction.parse( - findElementOrNull(element, "media:restriction"), + findElementOrNull(element, 'media:restriction'), ), community: Community.parse( - findElementOrNull(element, "media:community"), + findElementOrNull(element, 'media:community'), ), - comments: findElementOrNull(element, "media:comments") - ?.findElements("media:comment") + comments: findElementOrNull(element, 'media:comments') + ?.findElements('media:comment') ?.map((e) { return e.text; })?.toList() ?? [], embed: Embed.parse( - findElementOrNull(element, "media:embed"), + findElementOrNull(element, 'media:embed'), ), - responses: findElementOrNull(element, "media:responses") - ?.findElements("media:response") + responses: findElementOrNull(element, 'media:responses') + ?.findElements('media:response') ?.map((e) { return e.text; })?.toList() ?? [], - backLinks: findElementOrNull(element, "media:backLinks") - ?.findElements("media:backLink") + backLinks: findElementOrNull(element, 'media:backLinks') + ?.findElements('media:backLink') ?.map((e) { return e.text; })?.toList() ?? [], status: Status.parse( - findElementOrNull(element, "media:status"), + findElementOrNull(element, 'media:status'), ), - prices: element.findElements("media:price").map((e) { + prices: element.findElements('media:price').map((e) { return Price.parse(e); }).toList(), license: License.parse( - findElementOrNull(element, "media:license"), + findElementOrNull(element, 'media:license'), ), peerLink: PeerLink.parse( - findElementOrNull(element, "media:peerLink"), + findElementOrNull(element, 'media:peerLink'), ), rights: Rights.parse( - findElementOrNull(element, "media:rights"), + findElementOrNull(element, 'media:rights'), ), - scenes: findElementOrNull(element, "media:scenes") - ?.findElements("media:scene") + scenes: findElementOrNull(element, 'media:scenes') + ?.findElements('media:scene') ?.map((e) { return Scene.parse(e); })?.toList() ?? diff --git a/lib/domain/media/param.dart b/lib/domain/media/param.dart index f6299c8..ac42675 100644 --- a/lib/domain/media/param.dart +++ b/lib/domain/media/param.dart @@ -14,7 +14,7 @@ class Param { return null; } return Param( - name: element.getAttribute("name"), + name: element.getAttribute('name'), value: element.text, ); } diff --git a/lib/domain/media/peer_link.dart b/lib/domain/media/peer_link.dart index dd06d90..08a5524 100644 --- a/lib/domain/media/peer_link.dart +++ b/lib/domain/media/peer_link.dart @@ -16,8 +16,8 @@ class PeerLink { return null; } return PeerLink( - type: element.getAttribute("type"), - href: element.getAttribute("href"), + type: element.getAttribute('type'), + href: element.getAttribute('href'), value: element.text, ); } diff --git a/lib/domain/media/player.dart b/lib/domain/media/player.dart index 14b2a54..2036445 100644 --- a/lib/domain/media/player.dart +++ b/lib/domain/media/player.dart @@ -18,9 +18,9 @@ class Player { return null; } return Player( - url: element.getAttribute("url"), - width: int.tryParse(element.getAttribute("width") ?? "0"), - height: int.tryParse(element.getAttribute("height") ?? "0"), + url: element.getAttribute('url'), + width: int.tryParse(element.getAttribute('width') ?? '0'), + height: int.tryParse(element.getAttribute('height') ?? '0'), value: element.text, ); } diff --git a/lib/domain/media/price.dart b/lib/domain/media/price.dart index 6b930ce..4ac9059 100644 --- a/lib/domain/media/price.dart +++ b/lib/domain/media/price.dart @@ -15,10 +15,10 @@ class Price { factory Price.parse(XmlElement element) { return Price( - price: double.tryParse(element.getAttribute("price") ?? "0"), - type: element.getAttribute("type"), - info: element.getAttribute("info"), - currency: element.getAttribute("currency"), + price: double.tryParse(element.getAttribute('price') ?? '0'), + type: element.getAttribute('type'), + info: element.getAttribute('info'), + currency: element.getAttribute('currency'), ); } } diff --git a/lib/domain/media/rating.dart b/lib/domain/media/rating.dart index 5a53f88..7924cdd 100644 --- a/lib/domain/media/rating.dart +++ b/lib/domain/media/rating.dart @@ -14,7 +14,7 @@ class Rating { return null; } return Rating( - scheme: element.getAttribute("scheme"), + scheme: element.getAttribute('scheme'), value: element.text, ); } diff --git a/lib/domain/media/restriction.dart b/lib/domain/media/restriction.dart index 59a5339..cc896e9 100644 --- a/lib/domain/media/restriction.dart +++ b/lib/domain/media/restriction.dart @@ -16,8 +16,8 @@ class Restriction { return null; } return Restriction( - relationship: element.getAttribute("relationship"), - type: element.getAttribute("type"), + relationship: element.getAttribute('relationship'), + type: element.getAttribute('type'), value: element.text, ); } diff --git a/lib/domain/media/rights.dart b/lib/domain/media/rights.dart index 38feed3..2dfd20b 100644 --- a/lib/domain/media/rights.dart +++ b/lib/domain/media/rights.dart @@ -12,7 +12,7 @@ class Rights { return null; } return Rights( - status: element.getAttribute("status"), + status: element.getAttribute('status'), ); } } diff --git a/lib/domain/media/scene.dart b/lib/domain/media/scene.dart index 1336dc9..19e730e 100644 --- a/lib/domain/media/scene.dart +++ b/lib/domain/media/scene.dart @@ -19,10 +19,10 @@ class Scene { return null; } return Scene( - title: findElementOrNull(element, "sceneTitle")?.text, - description: findElementOrNull(element, "sceneDescription")?.text, - startTime: findElementOrNull(element, "sceneStartTime")?.text, - endTime: findElementOrNull(element, "sceneEndTime")?.text, + title: findElementOrNull(element, 'sceneTitle')?.text, + description: findElementOrNull(element, 'sceneDescription')?.text, + startTime: findElementOrNull(element, 'sceneStartTime')?.text, + endTime: findElementOrNull(element, 'sceneEndTime')?.text, ); } } diff --git a/lib/domain/media/star_rating.dart b/lib/domain/media/star_rating.dart index 9fc456b..9348a5a 100644 --- a/lib/domain/media/star_rating.dart +++ b/lib/domain/media/star_rating.dart @@ -15,10 +15,10 @@ class StarRating { factory StarRating.parse(XmlElement element) { return StarRating( - average: double.tryParse(element.getAttribute("average") ?? "0"), - count: int.tryParse(element.getAttribute("count") ?? "0"), - min: int.tryParse(element.getAttribute("min") ?? "0"), - max: int.tryParse(element.getAttribute("max") ?? "0"), + average: double.tryParse(element.getAttribute('average') ?? '0'), + count: int.tryParse(element.getAttribute('count') ?? '0'), + min: int.tryParse(element.getAttribute('min') ?? '0'), + max: int.tryParse(element.getAttribute('max') ?? '0'), ); } } diff --git a/lib/domain/media/statistics.dart b/lib/domain/media/statistics.dart index d30b025..01ade1e 100644 --- a/lib/domain/media/statistics.dart +++ b/lib/domain/media/statistics.dart @@ -11,8 +11,8 @@ class Statistics { factory Statistics.parse(XmlElement element) { return Statistics( - views: int.tryParse(element.getAttribute("views") ?? "0"), - favorites: int.tryParse(element.getAttribute("favorites") ?? "0"), + views: int.tryParse(element.getAttribute('views') ?? '0'), + favorites: int.tryParse(element.getAttribute('favorites') ?? '0'), ); } } diff --git a/lib/domain/media/status.dart b/lib/domain/media/status.dart index 17200ac..a5f0b15 100644 --- a/lib/domain/media/status.dart +++ b/lib/domain/media/status.dart @@ -14,8 +14,8 @@ class Status { return null; } return Status( - state: element.getAttribute("state"), - reason: element.getAttribute("reason"), + state: element.getAttribute('state'), + reason: element.getAttribute('reason'), ); } } diff --git a/lib/domain/media/tags.dart b/lib/domain/media/tags.dart index 3617a0a..b3f747d 100644 --- a/lib/domain/media/tags.dart +++ b/lib/domain/media/tags.dart @@ -15,7 +15,7 @@ class Tags { } return Tags( tags: element.text, - weight: int.tryParse(element.getAttribute("weight") ?? "1"), + weight: int.tryParse(element.getAttribute('weight') ?? '1'), ); } } diff --git a/lib/domain/media/text.dart b/lib/domain/media/text.dart index 702e934..58e8d21 100644 --- a/lib/domain/media/text.dart +++ b/lib/domain/media/text.dart @@ -20,10 +20,10 @@ class Text { return null; } return Text( - type: element.getAttribute("type"), - lang: element.getAttribute("lang"), - start: element.getAttribute("start"), - end: element.getAttribute("end"), + type: element.getAttribute('type'), + lang: element.getAttribute('lang'), + start: element.getAttribute('start'), + end: element.getAttribute('end'), value: element.text, ); } diff --git a/lib/domain/media/thumbnail.dart b/lib/domain/media/thumbnail.dart index 0c3f31c..85d81e7 100644 --- a/lib/domain/media/thumbnail.dart +++ b/lib/domain/media/thumbnail.dart @@ -15,10 +15,10 @@ class Thumbnail { factory Thumbnail.parse(XmlElement element) { return Thumbnail( - url: element.getAttribute("url"), - width: element.getAttribute("width"), - height: element.getAttribute("height"), - time: element.getAttribute("time"), + url: element.getAttribute('url'), + width: element.getAttribute('width'), + height: element.getAttribute('height'), + time: element.getAttribute('time'), ); } } diff --git a/lib/domain/media/title.dart b/lib/domain/media/title.dart index 49482d6..9968bce 100644 --- a/lib/domain/media/title.dart +++ b/lib/domain/media/title.dart @@ -14,7 +14,7 @@ class Title { return null; } return Title( - type: element.getAttribute("type"), + type: element.getAttribute('type'), value: element.text, ); } diff --git a/lib/domain/rss_category.dart b/lib/domain/rss_category.dart index 845a837..a3ca7d7 100644 --- a/lib/domain/rss_category.dart +++ b/lib/domain/rss_category.dart @@ -10,7 +10,7 @@ class RssCategory { if (element == null) { return null; } - var domain = element.getAttribute("domain"); + var domain = element.getAttribute('domain'); var value = element.text; return RssCategory(domain, value); diff --git a/lib/domain/rss_cloud.dart b/lib/domain/rss_cloud.dart index 74d8b6a..73f3c32 100644 --- a/lib/domain/rss_cloud.dart +++ b/lib/domain/rss_cloud.dart @@ -19,11 +19,11 @@ class RssCloud { if (node == null) { return null; } - var domain = node.getAttribute("domain"); - var port = node.getAttribute("port"); - var path = node.getAttribute("path"); - var registerProcedure = node.getAttribute("registerProcedure"); - var protocol = node.getAttribute("protocol"); + var domain = node.getAttribute('domain'); + var port = node.getAttribute('port'); + var path = node.getAttribute('path'); + var registerProcedure = node.getAttribute('registerProcedure'); + var protocol = node.getAttribute('protocol'); return RssCloud(domain, port, path, registerProcedure, protocol); } } diff --git a/lib/domain/rss_enclosure.dart b/lib/domain/rss_enclosure.dart index 4b125e2..dd303c7 100644 --- a/lib/domain/rss_enclosure.dart +++ b/lib/domain/rss_enclosure.dart @@ -11,9 +11,9 @@ class RssEnclosure { if (element == null) { return null; } - var url = element.getAttribute("url"); - var type = element.getAttribute("type"); - var length = int.tryParse(element.getAttribute("length") ?? "0"); + var url = element.getAttribute('url'); + var type = element.getAttribute('type'); + var length = int.tryParse(element.getAttribute('length') ?? '0'); return RssEnclosure(url, type, length); } } diff --git a/lib/domain/rss_feed.dart b/lib/domain/rss_feed.dart index 880f8e3..2235fe4 100644 --- a/lib/domain/rss_feed.dart +++ b/lib/domain/rss_feed.dart @@ -62,45 +62,45 @@ class RssFeed { var document = XmlDocument.parse(xmlString); XmlElement channelElement; try { - channelElement = document.findAllElements("channel").first; + channelElement = document.findAllElements('channel').first; } on StateError { - throw ArgumentError("channel not found"); + throw ArgumentError('channel not found'); } return RssFeed( - title: findElementOrNull(channelElement, "title")?.text, - author: findElementOrNull(channelElement, "author")?.text, - description: findElementOrNull(channelElement, "description")?.text, - link: findElementOrNull(channelElement, "link")?.text, - items: channelElement.findElements("item").map((element) { + title: findElementOrNull(channelElement, 'title')?.text, + author: findElementOrNull(channelElement, 'author')?.text, + description: findElementOrNull(channelElement, 'description')?.text, + link: findElementOrNull(channelElement, 'link')?.text, + items: channelElement.findElements('item').map((element) { return RssItem.parse(element); }).toList(), - image: RssImage.parse(findElementOrNull(channelElement, "image")), - cloud: RssCloud.parse(findElementOrNull(channelElement, "cloud")), - categories: channelElement.findElements("category").map((element) { + image: RssImage.parse(findElementOrNull(channelElement, 'image')), + cloud: RssCloud.parse(findElementOrNull(channelElement, 'cloud')), + categories: channelElement.findElements('category').map((element) { return RssCategory.parse(element); }).toList(), - skipDays: findElementOrNull(channelElement, "skipDays") - ?.findAllElements("day") + skipDays: findElementOrNull(channelElement, 'skipDays') + ?.findAllElements('day') ?.map((element) { return element.text; })?.toList() ?? [], - skipHours: findElementOrNull(channelElement, "skipHours") - ?.findAllElements("hour") + skipHours: findElementOrNull(channelElement, 'skipHours') + ?.findAllElements('hour') ?.map((element) { - return int.tryParse(element.text ?? "0"); + return int.tryParse(element.text ?? '0'); })?.toList() ?? [], - lastBuildDate: findElementOrNull(channelElement, "lastBuildDate")?.text, - language: findElementOrNull(channelElement, "language")?.text, - generator: findElementOrNull(channelElement, "generator")?.text, - copyright: findElementOrNull(channelElement, "copyright")?.text, - docs: findElementOrNull(channelElement, "docs")?.text, - managingEditor: findElementOrNull(channelElement, "managingEditor")?.text, - rating: findElementOrNull(channelElement, "rating")?.text, - webMaster: findElementOrNull(channelElement, "webMaster")?.text, - ttl: int.tryParse(findElementOrNull(channelElement, "ttl")?.text ?? "0"), + lastBuildDate: findElementOrNull(channelElement, 'lastBuildDate')?.text, + language: findElementOrNull(channelElement, 'language')?.text, + generator: findElementOrNull(channelElement, 'generator')?.text, + copyright: findElementOrNull(channelElement, 'copyright')?.text, + docs: findElementOrNull(channelElement, 'docs')?.text, + managingEditor: findElementOrNull(channelElement, 'managingEditor')?.text, + rating: findElementOrNull(channelElement, 'rating')?.text, + webMaster: findElementOrNull(channelElement, 'webMaster')?.text, + ttl: int.tryParse(findElementOrNull(channelElement, 'ttl')?.text ?? '0'), dc: DublinCore.parse(channelElement), itunes: RssItunes.parse(channelElement), ); diff --git a/lib/domain/rss_image.dart b/lib/domain/rss_image.dart index 447b628..9ed4e33 100644 --- a/lib/domain/rss_image.dart +++ b/lib/domain/rss_image.dart @@ -12,9 +12,9 @@ class RssImage { if (element == null) { return null; } - var title = findElementOrNull(element, "title")?.text; - var url = findElementOrNull(element, "url")?.text; - var link = findElementOrNull(element, "link")?.text; + var title = findElementOrNull(element, 'title')?.text; + var url = findElementOrNull(element, 'url')?.text; + var link = findElementOrNull(element, 'link')?.text; return RssImage(title, url, link); } diff --git a/lib/domain/rss_item.dart b/lib/domain/rss_item.dart index edecd9b..534399e 100644 --- a/lib/domain/rss_item.dart +++ b/lib/domain/rss_item.dart @@ -45,20 +45,20 @@ class RssItem { factory RssItem.parse(XmlElement element) { return RssItem( - title: findElementOrNull(element, "title")?.text, - description: findElementOrNull(element, "description")?.text, - link: findElementOrNull(element, "link")?.text, - categories: element.findElements("category").map((element) { + title: findElementOrNull(element, 'title')?.text, + description: findElementOrNull(element, 'description')?.text, + link: findElementOrNull(element, 'link')?.text, + categories: element.findElements('category').map((element) { return RssCategory.parse(element); }).toList(), - guid: findElementOrNull(element, "guid")?.text, - pubDate: parseDateTime(findElementOrNull(element, "pubDate")?.text), - author: findElementOrNull(element, "author")?.text, - comments: findElementOrNull(element, "comments")?.text, - source: RssSource.parse(findElementOrNull(element, "source")), - content: RssContent.parse(findElementOrNull(element, "content:encoded")), + guid: findElementOrNull(element, 'guid')?.text, + pubDate: parseDateTime(findElementOrNull(element, 'pubDate')?.text), + author: findElementOrNull(element, 'author')?.text, + comments: findElementOrNull(element, 'comments')?.text, + source: RssSource.parse(findElementOrNull(element, 'source')), + content: RssContent.parse(findElementOrNull(element, 'content:encoded')), media: Media.parse(element), - enclosure: RssEnclosure.parse(findElementOrNull(element, "enclosure")), + enclosure: RssEnclosure.parse(findElementOrNull(element, 'enclosure')), dc: DublinCore.parse(element), itunes: RssItemItunes.parse(element), ); diff --git a/lib/domain/rss_item_itunes.dart b/lib/domain/rss_item_itunes.dart index 19f1c12..0c94044 100644 --- a/lib/domain/rss_item_itunes.dart +++ b/lib/domain/rss_item_itunes.dart @@ -40,31 +40,31 @@ class RssItemItunes { if (element == null) { return null; } - var episodeStr = findElementOrNull(element, "itunes:episode")?.text?.trim(); - var seasonStr = findElementOrNull(element, "itunes:season")?.text?.trim(); + var episodeStr = findElementOrNull(element, 'itunes:episode')?.text?.trim(); + var seasonStr = findElementOrNull(element, 'itunes:season')?.text?.trim(); var durationStr = - findElementOrNull(element, "itunes:duration")?.text?.trim(); + findElementOrNull(element, 'itunes:duration')?.text?.trim(); return RssItemItunes( - title: findElementOrNull(element, "itunes:title")?.text?.trim(), + title: findElementOrNull(element, 'itunes:title')?.text?.trim(), episode: episodeStr == null ? null : int.parse(episodeStr), season: seasonStr == null ? null : int.parse(seasonStr), duration: durationStr == null ? null : parseDuration(durationStr), episodeType: newRssItunesEpisodeType( - findElementOrNull(element, "itunes:episodeType")), - author: findElementOrNull(element, "itunes:author")?.text?.trim(), - summary: findElementOrNull(element, "itunes:summary")?.text?.trim(), - explicit: parseBoolLiteral(element, "itunes:explicit"), - subtitle: findElementOrNull(element, "itunes:subtitle")?.text?.trim(), - keywords: findElementOrNull(element, "itunes:keywords") + findElementOrNull(element, 'itunes:episodeType')), + author: findElementOrNull(element, 'itunes:author')?.text?.trim(), + summary: findElementOrNull(element, 'itunes:summary')?.text?.trim(), + explicit: parseBoolLiteral(element, 'itunes:explicit'), + subtitle: findElementOrNull(element, 'itunes:subtitle')?.text?.trim(), + keywords: findElementOrNull(element, 'itunes:keywords') ?.text - ?.split(",") + ?.split(',') ?.map((keyword) => keyword.trim()) ?.toList(), - image: RssItunesImage.parse(findElementOrNull(element, "itunes:image")), + image: RssItunesImage.parse(findElementOrNull(element, 'itunes:image')), category: RssItunesCategory.parse( - findElementOrNull(element, "itunes:category")), - block: parseBoolLiteral(element, "itunes:block"), + findElementOrNull(element, 'itunes:category')), + block: parseBoolLiteral(element, 'itunes:block'), ); } } diff --git a/lib/domain/rss_itunes.dart b/lib/domain/rss_itunes.dart index e4e7685..af0b9e9 100644 --- a/lib/domain/rss_itunes.dart +++ b/lib/domain/rss_itunes.dart @@ -42,26 +42,26 @@ class RssItunes { return null; } return RssItunes( - author: findElementOrNull(element, "itunes:author")?.text?.trim(), - summary: findElementOrNull(element, "itunes:summary")?.text?.trim(), - explicit: parseBoolLiteral(element, "itunes:explicit"), - title: findElementOrNull(element, "itunes:title")?.text?.trim(), - subtitle: findElementOrNull(element, "itunes:subtitle")?.text?.trim(), - owner: RssItunesOwner.parse(findElementOrNull(element, "itunes:owner")), - keywords: findElementOrNull(element, "itunes:keywords") + author: findElementOrNull(element, 'itunes:author')?.text?.trim(), + summary: findElementOrNull(element, 'itunes:summary')?.text?.trim(), + explicit: parseBoolLiteral(element, 'itunes:explicit'), + title: findElementOrNull(element, 'itunes:title')?.text?.trim(), + subtitle: findElementOrNull(element, 'itunes:subtitle')?.text?.trim(), + owner: RssItunesOwner.parse(findElementOrNull(element, 'itunes:owner')), + keywords: findElementOrNull(element, 'itunes:keywords') ?.text - ?.split(",") + ?.split(',') ?.map((keyword) => keyword.trim()) ?.toList(), - image: RssItunesImage.parse(findElementOrNull(element, "itunes:image")), - categories: findAllDirectElementsOrNull(element, "itunes:category") + image: RssItunesImage.parse(findElementOrNull(element, 'itunes:image')), + categories: findAllDirectElementsOrNull(element, 'itunes:category') .map((ele) => RssItunesCategory.parse(ele)) .toList(), - type: newRssItunesType(findElementOrNull(element, "itunes:type")), + type: newRssItunesType(findElementOrNull(element, 'itunes:type')), newFeedUrl: - findElementOrNull(element, "itunes:new-feed-url")?.text?.trim(), - block: parseBoolLiteral(element, "itunes:block"), - complete: parseBoolLiteral(element, "itunes:complete"), + findElementOrNull(element, 'itunes:new-feed-url')?.text?.trim(), + block: parseBoolLiteral(element, 'itunes:block'), + complete: parseBoolLiteral(element, 'itunes:complete'), ); } } diff --git a/lib/domain/rss_itunes_category.dart b/lib/domain/rss_itunes_category.dart index b79f339..f6b7334 100644 --- a/lib/domain/rss_itunes_category.dart +++ b/lib/domain/rss_itunes_category.dart @@ -11,14 +11,15 @@ class RssItunesCategory { Iterable subCategories; try { - subCategories = element.findElements("itunes:category"); + subCategories = element.findElements('itunes:category'); } on StateError { subCategories = null; } return RssItunesCategory( - category: element.getAttribute("text")?.trim(), - subCategories: - subCategories?.map((ele) => ele.getAttribute("text")?.trim())?.toList(), + category: element.getAttribute('text')?.trim(), + subCategories: subCategories + ?.map((ele) => ele.getAttribute('text')?.trim()) + ?.toList(), ); } } diff --git a/lib/domain/rss_itunes_episode_type.dart b/lib/domain/rss_itunes_episode_type.dart index 30e639d..ffbf960 100644 --- a/lib/domain/rss_itunes_episode_type.dart +++ b/lib/domain/rss_itunes_episode_type.dart @@ -1,17 +1,17 @@ import 'package:xml/xml.dart'; -enum RssItunesEpisodeType {full, trailer, bonus} +enum RssItunesEpisodeType { full, trailer, bonus } RssItunesEpisodeType newRssItunesEpisodeType(XmlElement element) { // "full" is default type if (element == null) return RssItunesEpisodeType.full; switch (element.text) { - case "full": + case 'full': return RssItunesEpisodeType.full; - case "trailer": + case 'trailer': return RssItunesEpisodeType.trailer; - case "bonus": + case 'bonus': return RssItunesEpisodeType.bonus; default: return null; diff --git a/lib/domain/rss_itunes_image.dart b/lib/domain/rss_itunes_image.dart index 7b2ef2f..8328979 100644 --- a/lib/domain/rss_itunes_image.dart +++ b/lib/domain/rss_itunes_image.dart @@ -8,7 +8,7 @@ class RssItunesImage { factory RssItunesImage.parse(XmlElement element) { if (element == null) return null; return RssItunesImage( - href: element.getAttribute("href")?.trim(), + href: element.getAttribute('href')?.trim(), ); } } diff --git a/lib/domain/rss_itunes_owner.dart b/lib/domain/rss_itunes_owner.dart index 2d72294..e0bc605 100644 --- a/lib/domain/rss_itunes_owner.dart +++ b/lib/domain/rss_itunes_owner.dart @@ -11,8 +11,8 @@ class RssItunesOwner { factory RssItunesOwner.parse(XmlElement element) { if (element == null) return null; return RssItunesOwner( - name: findElementOrNull(element, "itunes:name")?.text?.trim(), - email: findElementOrNull(element, "itunes:email")?.text?.trim(), + name: findElementOrNull(element, 'itunes:name')?.text?.trim(), + email: findElementOrNull(element, 'itunes:email')?.text?.trim(), ); } } diff --git a/lib/domain/rss_itunes_type.dart b/lib/domain/rss_itunes_type.dart index b2cb031..b5c846f 100644 --- a/lib/domain/rss_itunes_type.dart +++ b/lib/domain/rss_itunes_type.dart @@ -3,13 +3,13 @@ import 'package:xml/xml.dart'; enum RssItunesType { episodic, serial } RssItunesType newRssItunesType(XmlElement element) { - // "episodic" is default type + // 'episodic' is default type if (element == null) return RssItunesType.episodic; switch (element.text) { - case "episodic": + case 'episodic': return RssItunesType.episodic; - case "serial": + case 'serial': return RssItunesType.serial; default: return null; diff --git a/lib/domain/rss_source.dart b/lib/domain/rss_source.dart index 6d82be8..056fe7b 100644 --- a/lib/domain/rss_source.dart +++ b/lib/domain/rss_source.dart @@ -10,7 +10,7 @@ class RssSource { if (element == null) { return null; } - var url = element.getAttribute("url"); + var url = element.getAttribute('url'); var value = element.text; return RssSource(url, value); diff --git a/lib/util/xml.dart b/lib/util/xml.dart index 179926c..113a8c1 100644 --- a/lib/util/xml.dart +++ b/lib/util/xml.dart @@ -23,6 +23,5 @@ List findAllDirectElementsOrNull(XmlElement element, String name, bool parseBoolLiteral(XmlElement element, String tagName) { var v = findElementOrNull(element, tagName)?.text?.toLowerCase()?.trim(); if (v == null) return null; - return ["yes", "true"].contains(v); + return ['yes', 'true'].contains(v); } - diff --git a/test/atom_test.dart b/test/atom_test.dart index f3b9c12..1cd24fc 100644 --- a/test/atom_test.dart +++ b/test/atom_test.dart @@ -5,95 +5,95 @@ import 'package:test/test.dart'; import 'package:webfeed/webfeed.dart'; void main() { - test("parse Invalid.xml", () { - var xmlString = File("test/xml/Invalid.xml").readAsStringSync(); + test('parse Invalid.xml', () { + var xmlString = File('test/xml/Invalid.xml').readAsStringSync(); try { AtomFeed.parse(xmlString); - fail("Should throw Argument Error"); + fail('Should throw Argument Error'); } on ArgumentError {} }); - test("parse Atom.xml", () { - var xmlString = File("test/xml/Atom.xml").readAsStringSync(); + test('parse Atom.xml', () { + var xmlString = File('test/xml/Atom.xml').readAsStringSync(); var feed = AtomFeed.parse(xmlString); - expect(feed.id, "foo-bar-id"); - expect(feed.title, "Foo bar news"); + expect(feed.id, 'foo-bar-id'); + expect(feed.title, 'Foo bar news'); expect(feed.updated, DateTime.utc(2018, 4, 6, 13, 2, 46)); expect(feed.links.length, 2); - expect(feed.links.first.rel, "foo"); - expect(feed.links.first.type, "text/html"); - expect(feed.links.first.hreflang, "en"); - expect(feed.links.first.href, "http://foo.bar.news/"); - expect(feed.links.first.title, "Foo bar news html"); + expect(feed.links.first.rel, 'foo'); + expect(feed.links.first.type, 'text/html'); + expect(feed.links.first.hreflang, 'en'); + expect(feed.links.first.href, 'http://foo.bar.news/'); + expect(feed.links.first.title, 'Foo bar news html'); expect(feed.links.first.length, 1000); expect(feed.authors.length, 2); - expect(feed.authors.first.name, "Alice"); - expect(feed.authors.first.uri, "http://foo.bar.news/people/alice"); - expect(feed.authors.first.email, "alice@foo.bar.news"); + expect(feed.authors.first.name, 'Alice'); + expect(feed.authors.first.uri, 'http://foo.bar.news/people/alice'); + expect(feed.authors.first.email, 'alice@foo.bar.news'); expect(feed.contributors.length, 2); - expect(feed.contributors.first.name, "Charlie"); - expect(feed.contributors.first.uri, "http://foo.bar.news/people/charlie"); - expect(feed.contributors.first.email, "charlie@foo.bar.news"); + expect(feed.contributors.first.name, 'Charlie'); + expect(feed.contributors.first.uri, 'http://foo.bar.news/people/charlie'); + expect(feed.contributors.first.email, 'charlie@foo.bar.news'); expect(feed.categories.length, 2); - expect(feed.categories.first.term, "foo category"); - expect(feed.categories.first.scheme, "this-is-foo-scheme"); - expect(feed.categories.first.label, "this is foo label"); + expect(feed.categories.first.term, 'foo category'); + expect(feed.categories.first.scheme, 'this-is-foo-scheme'); + expect(feed.categories.first.label, 'this is foo label'); - expect(feed.generator.uri, "http://foo.bar.news/generator"); - expect(feed.generator.version, "1.0"); - expect(feed.generator.value, "Foo bar generator"); + expect(feed.generator.uri, 'http://foo.bar.news/generator'); + expect(feed.generator.version, '1.0'); + expect(feed.generator.value, 'Foo bar generator'); - expect(feed.icon, "http://foo.bar.news/icon.png"); - expect(feed.logo, "http://foo.bar.news/logo.png"); - expect(feed.subtitle, "This is subtitle"); + expect(feed.icon, 'http://foo.bar.news/icon.png'); + expect(feed.logo, 'http://foo.bar.news/logo.png'); + expect(feed.subtitle, 'This is subtitle'); expect(feed.items.length, 2); var item = feed.items.first; - expect(item.id, "foo-bar-entry-id-1"); - expect(item.title, "Foo bar item 1"); + expect(item.id, 'foo-bar-entry-id-1'); + expect(item.title, 'Foo bar item 1'); expect(item.updated, DateTime.utc(2018, 4, 6, 13, 2, 40)); expect(item.authors.length, 2); - expect(item.authors.first.name, "Ellie"); - expect(item.authors.first.uri, "http://foo.bar.news/people/ellie"); - expect(item.authors.first.email, "ellie@foo.bar.news"); + expect(item.authors.first.name, 'Ellie'); + expect(item.authors.first.uri, 'http://foo.bar.news/people/ellie'); + expect(item.authors.first.email, 'ellie@foo.bar.news'); expect(item.links.length, 2); - expect(item.links.first.rel, "foo entry"); - expect(item.links.first.type, "text/html"); - expect(item.links.first.hreflang, "en"); - expect(item.links.first.href, "http://foo.bar.news/entry"); - expect(item.links.first.title, "Foo bar news html"); + expect(item.links.first.rel, 'foo entry'); + expect(item.links.first.type, 'text/html'); + expect(item.links.first.hreflang, 'en'); + expect(item.links.first.href, 'http://foo.bar.news/entry'); + expect(item.links.first.title, 'Foo bar news html'); expect(item.links.first.length, 1000); expect(item.categories.length, 2); - expect(item.categories.first.term, "foo entry category"); - expect(item.categories.first.scheme, "this-is-foo-entry-scheme"); - expect(item.categories.first.label, "this is foo entry label"); + expect(item.categories.first.term, 'foo entry category'); + expect(item.categories.first.scheme, 'this-is-foo-entry-scheme'); + expect(item.categories.first.label, 'this is foo entry label'); expect(item.contributors.length, 2); - expect(item.contributors.first.name, "Gin"); - expect(item.contributors.first.uri, "http://foo.bar.news/people/gin"); - expect(item.contributors.first.email, "gin@foo.bar.news"); - - expect(item.published, "2018-04-06T13:02:49Z"); - expect(item.summary, "This is summary 1"); - expect(item.content, "This is content 1"); - expect(item.rights, "This is rights 1"); + expect(item.contributors.first.name, 'Gin'); + expect(item.contributors.first.uri, 'http://foo.bar.news/people/gin'); + expect(item.contributors.first.email, 'gin@foo.bar.news'); + + expect(item.published, '2018-04-06T13:02:49Z'); + expect(item.summary, 'This is summary 1'); + expect(item.content, 'This is content 1'); + expect(item.rights, 'This is rights 1'); }); - test("parse Atom-Media.xml", () { - var xmlString = File("test/xml/Atom-Media.xml").readAsStringSync(); + test('parse Atom-Media.xml', () { + var xmlString = File('test/xml/Atom-Media.xml').readAsStringSync(); var feed = AtomFeed.parse(xmlString); - expect(feed.id, "foo-bar-id"); - expect(feed.title, "Foo bar news"); + expect(feed.id, 'foo-bar-id'); + expect(feed.title, 'Foo bar news'); expect(feed.updated, DateTime.utc(2018, 4, 6, 13, 2, 46)); expect(feed.items.length, 1); @@ -101,17 +101,17 @@ void main() { var item = feed.items.first; expect(item.media.group.contents.length, 5); expect(item.media.group.credits.length, 2); - expect(item.media.group.category.value, "music/artist name/album/song"); - expect(item.media.group.rating.value, "nonadult"); + expect(item.media.group.category.value, 'music/artist name/album/song'); + expect(item.media.group.rating.value, 'nonadult'); expect(item.media.contents.length, 2); var mediaContent = item.media.contents.first; - expect(mediaContent.url, "http://www.foo.com/video.mov"); - expect(mediaContent.type, "video/quicktime"); + expect(mediaContent.url, 'http://www.foo.com/video.mov'); + expect(mediaContent.type, 'video/quicktime'); expect(mediaContent.fileSize, 2000); - expect(mediaContent.medium, "video"); + expect(mediaContent.medium, 'video'); expect(mediaContent.isDefault, true); - expect(mediaContent.expression, "full"); + expect(mediaContent.expression, 'full'); expect(mediaContent.bitrate, 128); expect(mediaContent.framerate, 25); expect(mediaContent.samplingrate, 44.1); @@ -119,54 +119,54 @@ void main() { expect(item.media.credits.length, 2); var mediaCredit = item.media.credits.first; - expect(mediaCredit.role, "owner1"); - expect(mediaCredit.scheme, "urn:yvs"); - expect(mediaCredit.value, "copyright holder of the entity"); + expect(mediaCredit.role, 'owner1'); + expect(mediaCredit.scheme, 'urn:yvs'); + expect(mediaCredit.value, 'copyright holder of the entity'); expect(item.media.category.scheme, - "http://search.yahoo.com/mrss/category_ schema"); - expect(item.media.category.label, "Music"); - expect(item.media.category.value, "music/artist/album/song"); + 'http://search.yahoo.com/mrss/category_ schema'); + expect(item.media.category.label, 'Music'); + expect(item.media.category.value, 'music/artist/album/song'); - expect(item.media.rating.scheme, "urn:simple"); - expect(item.media.rating.value, "adult"); + expect(item.media.rating.scheme, 'urn:simple'); + expect(item.media.rating.value, 'adult'); - expect(item.media.title.type, "plain"); + expect(item.media.title.type, 'plain'); expect(item.media.title.value, "The Judy's -- The Moo Song"); - expect(item.media.description.type, "plain"); + expect(item.media.description.type, 'plain'); expect(item.media.description.value, - "This was some really bizarre band I listened to as a young lad."); + 'This was some really bizarre band I listened to as a young lad.'); - expect(item.media.keywords, "kitty, cat, big dog, yarn, fluffy"); + expect(item.media.keywords, 'kitty, cat, big dog, yarn, fluffy'); expect(item.media.thumbnails.length, 2); var mediaThumbnail = item.media.thumbnails.first; - expect(mediaThumbnail.url, "http://www.foo.com/keyframe1.jpg"); - expect(mediaThumbnail.width, "75"); - expect(mediaThumbnail.height, "50"); - expect(mediaThumbnail.time, "12:05:01.123"); + expect(mediaThumbnail.url, 'http://www.foo.com/keyframe1.jpg'); + expect(mediaThumbnail.width, '75'); + expect(mediaThumbnail.height, '50'); + expect(mediaThumbnail.time, '12:05:01.123'); - expect(item.media.hash.algo, "md5"); - expect(item.media.hash.value, "dfdec888b72151965a34b4b59031290a"); + expect(item.media.hash.algo, 'md5'); + expect(item.media.hash.value, 'dfdec888b72151965a34b4b59031290a'); - expect(item.media.player.url, "http://www.foo.com/player?id=1111"); + expect(item.media.player.url, 'http://www.foo.com/player?id=1111'); expect(item.media.player.width, 400); expect(item.media.player.height, 200); - expect(item.media.player.value, ""); + expect(item.media.player.value, ''); - expect(item.media.copyright.url, "http://blah.com/additional-info.html"); - expect(item.media.copyright.value, "2005 FooBar Media"); + expect(item.media.copyright.url, 'http://blah.com/additional-info.html'); + expect(item.media.copyright.value, '2005 FooBar Media'); - expect(item.media.text.type, "plain"); - expect(item.media.text.lang, "en"); - expect(item.media.text.start, "00:00:03.000"); - expect(item.media.text.end, "00:00:10.000"); - expect(item.media.text.value, " Oh, say, can you see"); + expect(item.media.text.type, 'plain'); + expect(item.media.text.lang, 'en'); + expect(item.media.text.start, '00:00:03.000'); + expect(item.media.text.end, '00:00:10.000'); + expect(item.media.text.value, ' Oh, say, can you see'); - expect(item.media.restriction.relationship, "allow"); - expect(item.media.restriction.type, "country"); - expect(item.media.restriction.value, "au us"); + expect(item.media.restriction.relationship, 'allow'); + expect(item.media.restriction.type, 'country'); + expect(item.media.restriction.value, 'au us'); expect(item.media.community.starRating.average, 3.5); expect(item.media.community.starRating.count, 20); @@ -174,58 +174,58 @@ void main() { expect(item.media.community.starRating.max, 10); expect(item.media.community.statistics.views, 5); expect(item.media.community.statistics.favorites, 4); - expect(item.media.community.tags.tags, "news: 5, abc:3"); + expect(item.media.community.tags.tags, 'news: 5, abc:3'); expect(item.media.community.tags.weight, 1); expect(item.media.comments.length, 2); - expect(item.media.comments.first, "comment1"); - expect(item.media.comments.last, "comment2"); + expect(item.media.comments.first, 'comment1'); + expect(item.media.comments.last, 'comment2'); - expect(item.media.embed.url, "http://www.foo.com/player.swf"); + expect(item.media.embed.url, 'http://www.foo.com/player.swf'); expect(item.media.embed.width, 512); expect(item.media.embed.height, 323); expect(item.media.embed.params.length, 5); - expect(item.media.embed.params.first.name, "type"); + expect(item.media.embed.params.first.name, 'type'); expect( - item.media.embed.params.first.value, "application/x-shockwave-flash"); + item.media.embed.params.first.value, 'application/x-shockwave-flash'); expect(item.media.responses.length, 2); - expect(item.media.responses.first, "http://www.response1.com"); - expect(item.media.responses.last, "http://www.response2.com"); + expect(item.media.responses.first, 'http://www.response1.com'); + expect(item.media.responses.last, 'http://www.response2.com'); expect(item.media.backLinks.length, 2); - expect(item.media.backLinks.first, "http://www.backlink1.com"); - expect(item.media.backLinks.last, "http://www.backlink2.com"); + expect(item.media.backLinks.first, 'http://www.backlink1.com'); + expect(item.media.backLinks.last, 'http://www.backlink2.com'); - expect(item.media.status.state, "active"); + expect(item.media.status.state, 'active'); expect(item.media.status.reason, null); expect(item.media.prices.length, 2); expect(item.media.prices.first.price, 19.99); - expect(item.media.prices.first.type, "rent"); + expect(item.media.prices.first.type, 'rent'); expect( - item.media.prices.first.info, "http://www.dummy.jp/package_info.html"); - expect(item.media.prices.first.currency, "EUR"); + item.media.prices.first.info, 'http://www.dummy.jp/package_info.html'); + expect(item.media.prices.first.currency, 'EUR'); - expect(item.media.license.type, "text/html"); - expect(item.media.license.href, "http://www.licensehost.com/license"); - expect(item.media.license.value, " Sample license for a video"); + expect(item.media.license.type, 'text/html'); + expect(item.media.license.href, 'http://www.licensehost.com/license'); + expect(item.media.license.value, ' Sample license for a video'); - expect(item.media.peerLink.type, "application/x-bittorrent"); - expect(item.media.peerLink.href, "http://www.foo.org/sampleFile.torrent"); - expect(item.media.peerLink.value, ""); + expect(item.media.peerLink.type, 'application/x-bittorrent'); + expect(item.media.peerLink.href, 'http://www.foo.org/sampleFile.torrent'); + expect(item.media.peerLink.value, ''); - expect(item.media.rights.status, "official"); + expect(item.media.rights.status, 'official'); expect(item.media.scenes.length, 2); - expect(item.media.scenes.first.title, "sceneTitle1"); - expect(item.media.scenes.first.description, "sceneDesc1"); - expect(item.media.scenes.first.startTime, "00:15"); - expect(item.media.scenes.first.endTime, "00:45"); + expect(item.media.scenes.first.title, 'sceneTitle1'); + expect(item.media.scenes.first.description, 'sceneDesc1'); + expect(item.media.scenes.first.startTime, '00:15'); + expect(item.media.scenes.first.endTime, '00:45'); }); - test("parse Atom-Empty.xml", () { - var xmlString = File("test/xml/Atom-Empty.xml").readAsStringSync(); + test('parse Atom-Empty.xml', () { + var xmlString = File('test/xml/Atom-Empty.xml').readAsStringSync(); var feed = AtomFeed.parse(xmlString); diff --git a/test/rss_test.dart b/test/rss_test.dart index 16fc91e..8fa729f 100644 --- a/test/rss_test.dart +++ b/test/rss_test.dart @@ -7,54 +7,54 @@ import 'package:webfeed/domain/rss_itunes_type.dart'; import 'package:webfeed/webfeed.dart'; void main() { - test("parse Invalid.xml", () { - var xmlString = File("test/xml/Invalid.xml").readAsStringSync(); + test('parse Invalid.xml', () { + var xmlString = File('test/xml/Invalid.xml').readAsStringSync(); try { RssFeed.parse(xmlString); - fail("Should throw Argument Error"); + fail('Should throw Argument Error'); } on ArgumentError {} }); - test("parse RSS.xml", () { - var xmlString = File("test/xml/RSS.xml").readAsStringSync(); + test('parse RSS.xml', () { + var xmlString = File('test/xml/RSS.xml').readAsStringSync(); var feed = RssFeed.parse(xmlString); - expect(feed.title, "News - Foo bar News"); + expect(feed.title, 'News - Foo bar News'); expect(feed.description, - "Foo bar News and Updates feed provided by Foo bar, Inc."); - expect(feed.link, "https://foo.bar.news/"); - expect(feed.author, "hello@world.net"); - expect(feed.language, "en-US"); - expect(feed.lastBuildDate, "Mon, 26 Mar 2018 14:00:00 PDT"); - expect(feed.generator, "Custom"); - expect(feed.copyright, "Copyright 2018, Foo bar Inc."); - expect(feed.docs, "https://foo.bar.news/docs"); - expect(feed.managingEditor, "alice@foo.bar.news"); - expect(feed.rating, "The PICS rating of the feed"); - expect(feed.webMaster, "webmaster@foo.bar.news"); + 'Foo bar News and Updates feed provided by Foo bar, Inc.'); + expect(feed.link, 'https://foo.bar.news/'); + expect(feed.author, 'hello@world.net'); + expect(feed.language, 'en-US'); + expect(feed.lastBuildDate, 'Mon, 26 Mar 2018 14:00:00 PDT'); + expect(feed.generator, 'Custom'); + expect(feed.copyright, 'Copyright 2018, Foo bar Inc.'); + expect(feed.docs, 'https://foo.bar.news/docs'); + expect(feed.managingEditor, 'alice@foo.bar.news'); + expect(feed.rating, 'The PICS rating of the feed'); + expect(feed.webMaster, 'webmaster@foo.bar.news'); expect(feed.ttl, 60); - expect(feed.image.title, "Foo bar News"); - expect(feed.image.url, "https://foo.bar.news/logo.gif"); - expect(feed.image.link, "https://foo.bar.news/"); + expect(feed.image.title, 'Foo bar News'); + expect(feed.image.url, 'https://foo.bar.news/logo.gif'); + expect(feed.image.link, 'https://foo.bar.news/'); - expect(feed.cloud.domain, "radio.foo.bar.news"); - expect(feed.cloud.port, "80"); - expect(feed.cloud.path, "/RPC2"); - expect(feed.cloud.registerProcedure, "foo.bar.rssPleaseNotify"); - expect(feed.cloud.protocol, "xml-rpc"); + expect(feed.cloud.domain, 'radio.foo.bar.news'); + expect(feed.cloud.port, '80'); + expect(feed.cloud.path, '/RPC2'); + expect(feed.cloud.registerProcedure, 'foo.bar.rssPleaseNotify'); + expect(feed.cloud.protocol, 'xml-rpc'); expect(feed.categories.length, 2); expect(feed.categories[0].domain, null); - expect(feed.categories[0].value, "Ipsum"); - expect(feed.categories[1].domain, "news"); - expect(feed.categories[1].value, "Lorem Ipsum"); + expect(feed.categories[0].value, 'Ipsum'); + expect(feed.categories[1].domain, 'news'); + expect(feed.categories[1].value, 'Lorem Ipsum'); expect(feed.skipDays.length, 3); - expect(feed.skipDays.contains("Monday"), true); - expect(feed.skipDays.contains("Tuesday"), true); - expect(feed.skipDays.contains("Sunday"), true); + expect(feed.skipDays.contains('Monday'), true); + expect(feed.skipDays.contains('Tuesday'), true); + expect(feed.skipDays.contains('Sunday'), true); expect(feed.skipHours.length, 5); expect(feed.skipHours.contains(0), true); @@ -66,58 +66,58 @@ void main() { expect(feed.items.length, 2); expect(feed.items.first.title, - "The standard Lorem Ipsum passage, used since the 1500s"); + 'The standard Lorem Ipsum passage, used since the 1500s'); expect(feed.items.first.description, - "Lorem ipsum dolor sit amet, consectetur adipiscing elit"); - expect(feed.items.first.link, "https://foo.bar.news/1"); - expect(feed.items.first.guid, "https://foo.bar.news/1?guid"); + 'Lorem ipsum dolor sit amet, consectetur adipiscing elit'); + expect(feed.items.first.link, 'https://foo.bar.news/1'); + expect(feed.items.first.guid, 'https://foo.bar.news/1?guid'); expect(feed.items.first.pubDate, DateTime(2018, 03, 26, 14)); //Mon, 26 Mar 2018 14:00:00 PDT - expect(feed.items.first.categories.first.domain, "news"); - expect(feed.items.first.categories.first.value, "Lorem"); - expect(feed.items.first.author, "alice@foo.bar.news"); - expect(feed.items.first.source.url, "https://foo.bar.news/1?source"); - expect(feed.items.first.source.value, "Foo Bar"); - expect(feed.items.first.comments, "https://foo.bar.news/1/comments"); + expect(feed.items.first.categories.first.domain, 'news'); + expect(feed.items.first.categories.first.value, 'Lorem'); + expect(feed.items.first.author, 'alice@foo.bar.news'); + expect(feed.items.first.source.url, 'https://foo.bar.news/1?source'); + expect(feed.items.first.source.value, 'Foo Bar'); + expect(feed.items.first.comments, 'https://foo.bar.news/1/comments'); expect(feed.items.first.enclosure.url, - "http://www.scripting.com/mp3s/weatherReportSuite.mp3"); + 'http://www.scripting.com/mp3s/weatherReportSuite.mp3'); expect(feed.items.first.enclosure.length, 12216320); - expect(feed.items.first.enclosure.type, "audio/mpeg"); + expect(feed.items.first.enclosure.type, 'audio/mpeg'); expect(feed.items.first.content.value, - " Test content
"); + ' Test content
'); expect( - feed.items.first.content.images.first, "https://test.com/image_link"); + feed.items.first.content.images.first, 'https://test.com/image_link'); }); - test("parse RSS-Media.xml", () { - var xmlString = File("test/xml/RSS-Media.xml").readAsStringSync(); + test('parse RSS-Media.xml', () { + var xmlString = File('test/xml/RSS-Media.xml').readAsStringSync(); var feed = RssFeed.parse(xmlString); - expect(feed.title, "Song Site"); + expect(feed.title, 'Song Site'); expect( - feed.description, "Media RSS example with new fields added in v1.5.0"); + feed.description, 'Media RSS example with new fields added in v1.5.0'); expect(feed.items.length, 1); var item = feed.items.first; expect(item.title, null); - expect(item.link, "http://www.foo.com"); + expect(item.link, 'http://www.foo.com'); expect(item.pubDate, DateTime(2001, 08, 27, 16, 08, 56)); //Mon, 27 Aug 2001 16:08:56 PST expect(item.media.group.contents.length, 5); expect(item.media.group.credits.length, 2); - expect(item.media.group.category.value, "music/artist name/album/song"); - expect(item.media.group.rating.value, "nonadult"); + expect(item.media.group.category.value, 'music/artist name/album/song'); + expect(item.media.group.rating.value, 'nonadult'); expect(item.media.contents.length, 2); var mediaContent = item.media.contents.first; - expect(mediaContent.url, "http://www.foo.com/video.mov"); - expect(mediaContent.type, "video/quicktime"); + expect(mediaContent.url, 'http://www.foo.com/video.mov'); + expect(mediaContent.type, 'video/quicktime'); expect(mediaContent.fileSize, 2000); - expect(mediaContent.medium, "video"); + expect(mediaContent.medium, 'video'); expect(mediaContent.isDefault, true); - expect(mediaContent.expression, "full"); + expect(mediaContent.expression, 'full'); expect(mediaContent.bitrate, 128); expect(mediaContent.framerate, 25); expect(mediaContent.samplingrate, 44.1); @@ -125,54 +125,54 @@ void main() { expect(item.media.credits.length, 2); var mediaCredit = item.media.credits.first; - expect(mediaCredit.role, "owner1"); - expect(mediaCredit.scheme, "urn:yvs"); - expect(mediaCredit.value, "copyright holder of the entity"); + expect(mediaCredit.role, 'owner1'); + expect(mediaCredit.scheme, 'urn:yvs'); + expect(mediaCredit.value, 'copyright holder of the entity'); expect(item.media.category.scheme, - "http://search.yahoo.com/mrss/category_ schema"); - expect(item.media.category.label, "Music"); - expect(item.media.category.value, "music/artist/album/song"); + 'http://search.yahoo.com/mrss/category_ schema'); + expect(item.media.category.label, 'Music'); + expect(item.media.category.value, 'music/artist/album/song'); - expect(item.media.rating.scheme, "urn:simple"); - expect(item.media.rating.value, "adult"); + expect(item.media.rating.scheme, 'urn:simple'); + expect(item.media.rating.value, 'adult'); - expect(item.media.title.type, "plain"); + expect(item.media.title.type, 'plain'); expect(item.media.title.value, "The Judy's -- The Moo Song"); - expect(item.media.description.type, "plain"); + expect(item.media.description.type, 'plain'); expect(item.media.description.value, - "This was some really bizarre band I listened to as a young lad."); + 'This was some really bizarre band I listened to as a young lad.'); - expect(item.media.keywords, "kitty, cat, big dog, yarn, fluffy"); + expect(item.media.keywords, 'kitty, cat, big dog, yarn, fluffy'); expect(item.media.thumbnails.length, 2); var mediaThumbnail = item.media.thumbnails.first; - expect(mediaThumbnail.url, "http://www.foo.com/keyframe1.jpg"); - expect(mediaThumbnail.width, "75"); - expect(mediaThumbnail.height, "50"); - expect(mediaThumbnail.time, "12:05:01.123"); + expect(mediaThumbnail.url, 'http://www.foo.com/keyframe1.jpg'); + expect(mediaThumbnail.width, '75'); + expect(mediaThumbnail.height, '50'); + expect(mediaThumbnail.time, '12:05:01.123'); - expect(item.media.hash.algo, "md5"); - expect(item.media.hash.value, "dfdec888b72151965a34b4b59031290a"); + expect(item.media.hash.algo, 'md5'); + expect(item.media.hash.value, 'dfdec888b72151965a34b4b59031290a'); - expect(item.media.player.url, "http://www.foo.com/player?id=1111"); + expect(item.media.player.url, 'http://www.foo.com/player?id=1111'); expect(item.media.player.width, 400); expect(item.media.player.height, 200); - expect(item.media.player.value, ""); + expect(item.media.player.value, ''); - expect(item.media.copyright.url, "http://blah.com/additional-info.html"); - expect(item.media.copyright.value, "2005 FooBar Media"); + expect(item.media.copyright.url, 'http://blah.com/additional-info.html'); + expect(item.media.copyright.value, '2005 FooBar Media'); - expect(item.media.text.type, "plain"); - expect(item.media.text.lang, "en"); - expect(item.media.text.start, "00:00:03.000"); - expect(item.media.text.end, "00:00:10.000"); - expect(item.media.text.value, " Oh, say, can you see"); + expect(item.media.text.type, 'plain'); + expect(item.media.text.lang, 'en'); + expect(item.media.text.start, '00:00:03.000'); + expect(item.media.text.end, '00:00:10.000'); + expect(item.media.text.value, ' Oh, say, can you see'); - expect(item.media.restriction.relationship, "allow"); - expect(item.media.restriction.type, "country"); - expect(item.media.restriction.value, "au us"); + expect(item.media.restriction.relationship, 'allow'); + expect(item.media.restriction.type, 'country'); + expect(item.media.restriction.value, 'au us'); expect(item.media.community.starRating.average, 3.5); expect(item.media.community.starRating.count, 20); @@ -180,97 +180,97 @@ void main() { expect(item.media.community.starRating.max, 10); expect(item.media.community.statistics.views, 5); expect(item.media.community.statistics.favorites, 4); - expect(item.media.community.tags.tags, "news: 5, abc:3"); + expect(item.media.community.tags.tags, 'news: 5, abc:3'); expect(item.media.community.tags.weight, 1); expect(item.media.comments.length, 2); - expect(item.media.comments.first, "comment1"); - expect(item.media.comments.last, "comment2"); + expect(item.media.comments.first, 'comment1'); + expect(item.media.comments.last, 'comment2'); - expect(item.media.embed.url, "http://www.foo.com/player.swf"); + expect(item.media.embed.url, 'http://www.foo.com/player.swf'); expect(item.media.embed.width, 512); expect(item.media.embed.height, 323); expect(item.media.embed.params.length, 5); - expect(item.media.embed.params.first.name, "type"); + expect(item.media.embed.params.first.name, 'type'); expect( - item.media.embed.params.first.value, "application/x-shockwave-flash"); + item.media.embed.params.first.value, 'application/x-shockwave-flash'); expect(item.media.responses.length, 2); - expect(item.media.responses.first, "http://www.response1.com"); - expect(item.media.responses.last, "http://www.response2.com"); + expect(item.media.responses.first, 'http://www.response1.com'); + expect(item.media.responses.last, 'http://www.response2.com'); expect(item.media.backLinks.length, 2); - expect(item.media.backLinks.first, "http://www.backlink1.com"); - expect(item.media.backLinks.last, "http://www.backlink2.com"); + expect(item.media.backLinks.first, 'http://www.backlink1.com'); + expect(item.media.backLinks.last, 'http://www.backlink2.com'); - expect(item.media.status.state, "active"); + expect(item.media.status.state, 'active'); expect(item.media.status.reason, null); expect(item.media.prices.length, 2); expect(item.media.prices.first.price, 19.99); - expect(item.media.prices.first.type, "rent"); + expect(item.media.prices.first.type, 'rent'); expect( - item.media.prices.first.info, "http://www.dummy.jp/package_info.html"); - expect(item.media.prices.first.currency, "EUR"); + item.media.prices.first.info, 'http://www.dummy.jp/package_info.html'); + expect(item.media.prices.first.currency, 'EUR'); - expect(item.media.license.type, "text/html"); - expect(item.media.license.href, "http://www.licensehost.com/license"); - expect(item.media.license.value, " Sample license for a video"); + expect(item.media.license.type, 'text/html'); + expect(item.media.license.href, 'http://www.licensehost.com/license'); + expect(item.media.license.value, ' Sample license for a video'); - expect(item.media.peerLink.type, "application/x-bittorrent"); - expect(item.media.peerLink.href, "http://www.foo.org/sampleFile.torrent"); - expect(item.media.peerLink.value, ""); + expect(item.media.peerLink.type, 'application/x-bittorrent'); + expect(item.media.peerLink.href, 'http://www.foo.org/sampleFile.torrent'); + expect(item.media.peerLink.value, ''); - expect(item.media.rights.status, "official"); + expect(item.media.rights.status, 'official'); expect(item.media.scenes.length, 2); - expect(item.media.scenes.first.title, "sceneTitle1"); - expect(item.media.scenes.first.description, "sceneDesc1"); - expect(item.media.scenes.first.startTime, "00:15"); - expect(item.media.scenes.first.endTime, "00:45"); + expect(item.media.scenes.first.title, 'sceneTitle1'); + expect(item.media.scenes.first.description, 'sceneDesc1'); + expect(item.media.scenes.first.startTime, '00:15'); + expect(item.media.scenes.first.endTime, '00:45'); }); - test("parse RSS-DC.xml", () { - var xmlString = File("test/xml/RSS-DC.xml").readAsStringSync(); + test('parse RSS-DC.xml', () { + var xmlString = File('test/xml/RSS-DC.xml').readAsStringSync(); var feed = RssFeed.parse(xmlString); - expect(feed.dc.title, "title"); - expect(feed.dc.creator, "creator"); - expect(feed.dc.subject, "subject"); - expect(feed.dc.description, "description"); - expect(feed.dc.publisher, "publisher"); - expect(feed.dc.contributor, "contributor"); + expect(feed.dc.title, 'title'); + expect(feed.dc.creator, 'creator'); + expect(feed.dc.subject, 'subject'); + expect(feed.dc.description, 'description'); + expect(feed.dc.publisher, 'publisher'); + expect(feed.dc.contributor, 'contributor'); expect(feed.dc.date, DateTime.utc(2000, 1, 1, 12)); expect(feed.dc.created, DateTime.utc(2000, 1, 1, 13)); expect(feed.dc.modified, DateTime.utc(2000, 1, 1, 14)); - expect(feed.dc.type, "type"); - expect(feed.dc.format, "format"); - expect(feed.dc.identifier, "identifier"); - expect(feed.dc.source, "source"); - expect(feed.dc.language, "language"); - expect(feed.dc.relation, "relation"); - expect(feed.dc.coverage, "coverage"); - expect(feed.dc.rights, "rights"); - - expect(feed.items.first.dc.title, "title"); - expect(feed.items.first.dc.creator, "creator"); - expect(feed.items.first.dc.subject, "subject"); - expect(feed.items.first.dc.description, "description"); - expect(feed.items.first.dc.publisher, "publisher"); - expect(feed.items.first.dc.contributor, "contributor"); + expect(feed.dc.type, 'type'); + expect(feed.dc.format, 'format'); + expect(feed.dc.identifier, 'identifier'); + expect(feed.dc.source, 'source'); + expect(feed.dc.language, 'language'); + expect(feed.dc.relation, 'relation'); + expect(feed.dc.coverage, 'coverage'); + expect(feed.dc.rights, 'rights'); + + expect(feed.items.first.dc.title, 'title'); + expect(feed.items.first.dc.creator, 'creator'); + expect(feed.items.first.dc.subject, 'subject'); + expect(feed.items.first.dc.description, 'description'); + expect(feed.items.first.dc.publisher, 'publisher'); + expect(feed.items.first.dc.contributor, 'contributor'); expect(feed.items.first.dc.date, DateTime.utc(2000, 1, 1, 12)); - expect(feed.items.first.dc.type, "type"); - expect(feed.items.first.dc.format, "format"); - expect(feed.items.first.dc.identifier, "identifier"); - expect(feed.items.first.dc.source, "source"); - expect(feed.items.first.dc.language, "language"); - expect(feed.items.first.dc.relation, "relation"); - expect(feed.items.first.dc.coverage, "coverage"); - expect(feed.items.first.dc.rights, "rights"); + expect(feed.items.first.dc.type, 'type'); + expect(feed.items.first.dc.format, 'format'); + expect(feed.items.first.dc.identifier, 'identifier'); + expect(feed.items.first.dc.source, 'source'); + expect(feed.items.first.dc.language, 'language'); + expect(feed.items.first.dc.relation, 'relation'); + expect(feed.items.first.dc.coverage, 'coverage'); + expect(feed.items.first.dc.rights, 'rights'); }); - test("parse RSS-Empty.xml", () { - var xmlString = File("test/xml/RSS-Empty.xml").readAsStringSync(); + test('parse RSS-Empty.xml', () { + var xmlString = File('test/xml/RSS-Empty.xml').readAsStringSync(); var feed = RssFeed.parse(xmlString); @@ -313,39 +313,39 @@ void main() { expect(feed.items.first.content, null); }); - test("parse RSS-Itunes.xml", () { - var xmlString = File("test/xml/RSS-Itunes.xml").readAsStringSync(); + test('parse RSS-Itunes.xml', () { + var xmlString = File('test/xml/RSS-Itunes.xml').readAsStringSync(); var feed = RssFeed.parse(xmlString); - expect(feed.itunes.author, "Changelog Media"); - expect(feed.itunes.summary, "Foo"); + expect(feed.itunes.author, 'Changelog Media'); + expect(feed.itunes.summary, 'Foo'); expect(feed.itunes.explicit, false); expect(feed.itunes.image.href, - "https://cdn.changelog.com/uploads/covers/go-time-original.png?v=63725770357"); + 'https://cdn.changelog.com/uploads/covers/go-time-original.png?v=63725770357'); expect(feed.itunes.keywords, - "go,golang,open source,software,development".split(",")); - expect(feed.itunes.owner.name, "Changelog Media"); - expect(feed.itunes.owner.email, "editors@changelog.com"); + 'go,golang,open source,software,development'.split(',')); + expect(feed.itunes.owner.name, 'Changelog Media'); + expect(feed.itunes.owner.email, 'editors@changelog.com'); expect( Set.from([ feed.itunes.categories[0].category, feed.itunes.categories[1].category ]), - ["Technology", "Foo"]); + ['Technology', 'Foo']); for (var category in feed.itunes.categories) { switch (category.category) { - case "Foo": - expect(category.subCategories, ["Bar", "Baz"]); + case 'Foo': + expect(category.subCategories, ['Bar', 'Baz']); break; - case "Technology": - expect(category.subCategories, ["Software How-To", "Tech News"]); + case 'Technology': + expect(category.subCategories, ['Software How-To', 'Tech News']); break; } } - expect(feed.itunes.title, "Go Time"); + expect(feed.itunes.title, 'Go Time'); expect(feed.itunes.type, RssItunesType.serial); - expect(feed.itunes.newFeedUrl, "wubawuba"); + expect(feed.itunes.newFeedUrl, 'wubawuba'); expect(feed.itunes.block, true); expect(feed.itunes.complete, true); @@ -354,17 +354,17 @@ void main() { expect(item.itunes.episode, 1); expect(item.itunes.season, 1); expect(item.itunes.image.href, - "https://cdn.changelog.com/uploads/covers/go-time-original.png?v=63725770357"); + 'https://cdn.changelog.com/uploads/covers/go-time-original.png?v=63725770357'); expect(item.itunes.duration, Duration(minutes: 32, seconds: 30)); expect(item.itunes.explicit, false); expect(item.itunes.keywords, - "go,golang,open source,software,development".split(",")); - expect(item.itunes.subtitle, "with Erik, Carlisia, and Brian"); - expect(item.itunes.summary, "Foo"); + 'go,golang,open source,software,development'.split(',')); + expect(item.itunes.subtitle, 'with Erik, Carlisia, and Brian'); + expect(item.itunes.summary, 'Foo'); expect(item.itunes.author, - "Erik St. Martin, Carlisia Pinto, and Brian Ketelsen"); + 'Erik St. Martin, Carlisia Pinto, and Brian Ketelsen'); expect(item.itunes.explicit, false); - expect(item.itunes.title, "awesome title"); + expect(item.itunes.title, 'awesome title'); expect(item.itunes.block, false); }); }