| @@ -0,0 +1,20 @@ | |||||
| import 'package:xml/xml.dart'; | |||||
| class RssCloud { | |||||
| String domain; | |||||
| String port; | |||||
| String path; | |||||
| String registerProcedure; | |||||
| String protocol; | |||||
| RssCloud(this.domain, this.port, this.path, this.registerProcedure, this.protocol); | |||||
| factory RssCloud.parse(XmlElement node) { | |||||
| 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 new RssCloud(domain, port, path, registerProcedure, protocol); | |||||
| } | |||||
| } | |||||
| @@ -1,6 +1,7 @@ | |||||
| import 'dart:core'; | import 'dart:core'; | ||||
| import 'package:webfeedclient/domain/rss_category.dart'; | import 'package:webfeedclient/domain/rss_category.dart'; | ||||
| import 'package:webfeedclient/domain/rss_cloud.dart'; | |||||
| import 'package:webfeedclient/domain/rss_item.dart'; | import 'package:webfeedclient/domain/rss_item.dart'; | ||||
| import 'package:webfeedclient/util/helpers.dart'; | import 'package:webfeedclient/util/helpers.dart'; | ||||
| import 'package:xml/xml.dart'; | import 'package:xml/xml.dart'; | ||||
| @@ -14,6 +15,7 @@ class RssFeed { | |||||
| final List<RssItem> items; | final List<RssItem> items; | ||||
| final RssImage image; | final RssImage image; | ||||
| final RssCloud cloud; | |||||
| final List<RssCategory> categories; | final List<RssCategory> categories; | ||||
| final String lastBuildDate; | final String lastBuildDate; | ||||
| final String language; | final String language; | ||||
| @@ -21,7 +23,7 @@ class RssFeed { | |||||
| final String copyright; | final String copyright; | ||||
| RssFeed(this.title, this.description, this.link, this.items, | RssFeed(this.title, this.description, this.link, this.items, | ||||
| {this.image, this.categories, this.lastBuildDate, this.language, this.generator, this.copyright}); | |||||
| {this.image, this.cloud, this.categories, this.lastBuildDate, this.language, this.generator, this.copyright}); | |||||
| factory RssFeed.parse(XmlDocument document) { | factory RssFeed.parse(XmlDocument document) { | ||||
| XmlElement channelElement; | XmlElement channelElement; | ||||
| @@ -43,6 +45,11 @@ class RssFeed { | |||||
| image = new RssImage.parse(channelElement.findElements("image").first); | image = new RssImage.parse(channelElement.findElements("image").first); | ||||
| } on StateError {} | } on StateError {} | ||||
| RssCloud cloud; | |||||
| try { | |||||
| cloud = new RssCloud.parse(channelElement.findElements("cloud").first); | |||||
| } on StateError {} | |||||
| List<RssCategory> categories = channelElement.findElements("category").map((element) { | List<RssCategory> categories = channelElement.findElements("category").map((element) { | ||||
| return new RssCategory.parse(element); | return new RssCategory.parse(element); | ||||
| }).toList(); | }).toList(); | ||||
| @@ -54,6 +61,7 @@ class RssFeed { | |||||
| return new RssFeed(title, description, link, feeds, | return new RssFeed(title, description, link, feeds, | ||||
| image: image, | image: image, | ||||
| cloud: cloud, | |||||
| categories: categories, | categories: categories, | ||||
| lastBuildDate: lastBuildDate, | lastBuildDate: lastBuildDate, | ||||
| language: language, | language: language, | ||||
| @@ -32,6 +32,12 @@ void main() { | |||||
| expect(feed.image.url, "https://foo.bar.news/logo.gif"); | expect(feed.image.url, "https://foo.bar.news/logo.gif"); | ||||
| expect(feed.image.link, "https://foo.bar.news/"); | 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.categories.length, 2); | expect(feed.categories.length, 2); | ||||
| expect(feed.categories[0].domain, null); | expect(feed.categories[0].domain, null); | ||||
| expect(feed.categories[0].value, "Ipsum"); | expect(feed.categories[0].value, "Ipsum"); | ||||
| @@ -9,6 +9,8 @@ | |||||
| <title>Foo bar News</title> | <title>Foo bar News</title> | ||||
| <link>https://foo.bar.news/</link> | <link>https://foo.bar.news/</link> | ||||
| </image> | </image> | ||||
| <cloud domain="radio.foo.bar.news" port="80" path="/RPC2" registerProcedure="foo.bar.rssPleaseNotify" | |||||
| protocol="xml-rpc"/> | |||||
| <category>Ipsum</category> | <category>Ipsum</category> | ||||
| <category domain="news">Lorem Ipsum</category> | <category domain="news">Lorem Ipsum</category> | ||||
| <language>en-US</language> | <language>en-US</language> | ||||
| @@ -27,7 +29,9 @@ | |||||
| <title>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC</title> | <title>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC</title> | ||||
| <link>https://foo.bar.news/2</link> | <link>https://foo.bar.news/2</link> | ||||
| <guid>https://foo.bar.news/2?guid</guid> | <guid>https://foo.bar.news/2?guid</guid> | ||||
| <description>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium</description> | |||||
| <description>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque | |||||
| laudantium | |||||
| </description> | |||||
| <category domain="auto">Ipsum</category> | <category domain="auto">Ipsum</category> | ||||
| <pubDate>Tue, 20 Mar 2018 10:00:00 PDT</pubDate> | <pubDate>Tue, 20 Mar 2018 10:00:00 PDT</pubDate> | ||||
| </item> | </item> | ||||