| @@ -33,3 +33,4 @@ linter: | |||
| - slash_for_doc_comments | |||
| - type_init_formals | |||
| - unnecessary_new | |||
| - prefer_single_quotes | |||
| @@ -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); | |||
| @@ -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); | |||
| } | |||
| } | |||
| @@ -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, | |||
| ); | |||
| } | |||
| } | |||
| @@ -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); | |||
| } | |||
| @@ -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), | |||
| ); | |||
| } | |||
| @@ -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); | |||
| } | |||
| @@ -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); | |||
| } | |||
| } | |||
| @@ -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); | |||
| } | |||
| @@ -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, | |||
| ); | |||
| } | |||
| } | |||
| @@ -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, | |||
| ); | |||
| } | |||
| @@ -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'), | |||
| ), | |||
| ); | |||
| } | |||
| @@ -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'), | |||
| ); | |||
| } | |||
| } | |||
| @@ -14,7 +14,7 @@ class Copyright { | |||
| return null; | |||
| } | |||
| return Copyright( | |||
| url: element.getAttribute("url"), | |||
| url: element.getAttribute('url'), | |||
| value: element.text, | |||
| ); | |||
| } | |||
| @@ -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, | |||
| ); | |||
| } | |||
| @@ -14,7 +14,7 @@ class Description { | |||
| return null; | |||
| } | |||
| return Description( | |||
| type: element.getAttribute("type"), | |||
| type: element.getAttribute('type'), | |||
| value: element.text, | |||
| ); | |||
| } | |||
| @@ -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(), | |||
| ); | |||
| @@ -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'), | |||
| ), | |||
| ); | |||
| } | |||
| @@ -14,7 +14,7 @@ class Hash { | |||
| return null; | |||
| } | |||
| return Hash( | |||
| algo: element.getAttribute("algo"), | |||
| algo: element.getAttribute('algo'), | |||
| value: element.text, | |||
| ); | |||
| } | |||
| @@ -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, | |||
| ); | |||
| } | |||
| @@ -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() ?? | |||
| @@ -14,7 +14,7 @@ class Param { | |||
| return null; | |||
| } | |||
| return Param( | |||
| name: element.getAttribute("name"), | |||
| name: element.getAttribute('name'), | |||
| value: element.text, | |||
| ); | |||
| } | |||
| @@ -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, | |||
| ); | |||
| } | |||
| @@ -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, | |||
| ); | |||
| } | |||
| @@ -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'), | |||
| ); | |||
| } | |||
| } | |||
| @@ -14,7 +14,7 @@ class Rating { | |||
| return null; | |||
| } | |||
| return Rating( | |||
| scheme: element.getAttribute("scheme"), | |||
| scheme: element.getAttribute('scheme'), | |||
| value: element.text, | |||
| ); | |||
| } | |||
| @@ -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, | |||
| ); | |||
| } | |||
| @@ -12,7 +12,7 @@ class Rights { | |||
| return null; | |||
| } | |||
| return Rights( | |||
| status: element.getAttribute("status"), | |||
| status: element.getAttribute('status'), | |||
| ); | |||
| } | |||
| } | |||
| @@ -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, | |||
| ); | |||
| } | |||
| } | |||
| @@ -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'), | |||
| ); | |||
| } | |||
| } | |||
| @@ -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'), | |||
| ); | |||
| } | |||
| } | |||
| @@ -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'), | |||
| ); | |||
| } | |||
| } | |||
| @@ -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'), | |||
| ); | |||
| } | |||
| } | |||
| @@ -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, | |||
| ); | |||
| } | |||
| @@ -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'), | |||
| ); | |||
| } | |||
| } | |||
| @@ -14,7 +14,7 @@ class Title { | |||
| return null; | |||
| } | |||
| return Title( | |||
| type: element.getAttribute("type"), | |||
| type: element.getAttribute('type'), | |||
| value: element.text, | |||
| ); | |||
| } | |||
| @@ -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); | |||
| @@ -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); | |||
| } | |||
| } | |||
| @@ -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); | |||
| } | |||
| } | |||
| @@ -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), | |||
| ); | |||
| @@ -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); | |||
| } | |||
| @@ -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), | |||
| ); | |||
| @@ -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'), | |||
| ); | |||
| } | |||
| } | |||
| @@ -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'), | |||
| ); | |||
| } | |||
| } | |||
| @@ -11,14 +11,15 @@ class RssItunesCategory { | |||
| Iterable<XmlElement> 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(), | |||
| ); | |||
| } | |||
| } | |||
| @@ -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; | |||
| @@ -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(), | |||
| ); | |||
| } | |||
| } | |||
| @@ -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(), | |||
| ); | |||
| } | |||
| } | |||
| @@ -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; | |||
| @@ -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); | |||
| @@ -23,6 +23,5 @@ List<XmlElement> 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); | |||
| } | |||
| @@ -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); | |||
| @@ -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, | |||
| "<img width=\"1000\" height=\"690\" src=\"https://test.com/image_link\"/> Test content<br />"); | |||
| '<img width="1000" height="690" src="https://test.com/image_link"/> Test content<br />'); | |||
| 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); | |||
| }); | |||
| } | |||