Procházet zdrojové kódy

add cloud support

master
Wito Chandra před 8 roky
rodič
revize
f21f087025
4 změnil soubory, kde provedl 40 přidání a 2 odebrání
  1. +20
    -0
      lib/domain/rss_cloud.dart
  2. +9
    -1
      lib/domain/rss_feed.dart
  3. +6
    -0
      test/rss_test.dart
  4. +5
    -1
      test/xml/RSS.xml

+ 20
- 0
lib/domain/rss_cloud.dart Zobrazit soubor

@@ -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);
}
}

+ 9
- 1
lib/domain/rss_feed.dart Zobrazit soubor

@@ -1,6 +1,7 @@
import 'dart:core';

import 'package:webfeedclient/domain/rss_category.dart';
import 'package:webfeedclient/domain/rss_cloud.dart';
import 'package:webfeedclient/domain/rss_item.dart';
import 'package:webfeedclient/util/helpers.dart';
import 'package:xml/xml.dart';
@@ -14,6 +15,7 @@ class RssFeed {
final List<RssItem> items;

final RssImage image;
final RssCloud cloud;
final List<RssCategory> categories;
final String lastBuildDate;
final String language;
@@ -21,7 +23,7 @@ class RssFeed {
final String copyright;

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) {
XmlElement channelElement;
@@ -43,6 +45,11 @@ class RssFeed {
image = new RssImage.parse(channelElement.findElements("image").first);
} on StateError {}

RssCloud cloud;
try {
cloud = new RssCloud.parse(channelElement.findElements("cloud").first);
} on StateError {}

List<RssCategory> categories = channelElement.findElements("category").map((element) {
return new RssCategory.parse(element);
}).toList();
@@ -54,6 +61,7 @@ class RssFeed {

return new RssFeed(title, description, link, feeds,
image: image,
cloud: cloud,
categories: categories,
lastBuildDate: lastBuildDate,
language: language,


+ 6
- 0
test/rss_test.dart Zobrazit soubor

@@ -32,6 +32,12 @@ void main() {
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.categories.length, 2);
expect(feed.categories[0].domain, null);
expect(feed.categories[0].value, "Ipsum");


+ 5
- 1
test/xml/RSS.xml Zobrazit soubor

@@ -9,6 +9,8 @@
<title>Foo bar News</title>
<link>https://foo.bar.news/</link>
</image>
<cloud domain="radio.foo.bar.news" port="80" path="/RPC2" registerProcedure="foo.bar.rssPleaseNotify"
protocol="xml-rpc"/>
<category>Ipsum</category>
<category domain="news">Lorem Ipsum</category>
<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>
<link>https://foo.bar.news/2</link>
<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>
<pubDate>Tue, 20 Mar 2018 10:00:00 PDT</pubDate>
</item>


Načítá se…
Zrušit
Uložit