Преглед изворни кода

add DateTime type for dublin core

master
Wito Chandra пре 6 година
родитељ
комит
7f82c09e26
4 измењених фајлова са 20 додато и 18 уклоњено
  1. +7
    -6
      lib/domain/dublin_core/dublin_core.dart
  2. +1
    -1
      pubspec.yaml
  3. +10
    -9
      test/rss_test.dart
  4. +2
    -2
      test/xml/RSS-DC.xml

+ 7
- 6
lib/domain/dublin_core/dublin_core.dart Прегледај датотеку

@@ -1,3 +1,4 @@
import 'package:webfeed/util/datetime.dart';
import 'package:webfeed/util/xml.dart';
import 'package:xml/xml.dart';

@@ -8,9 +9,9 @@ class DublinCore {
final String subject;
final String publisher;
final String contributor;
final String date;
final String created;
final String modified;
final DateTime date;
final DateTime created;
final DateTime modified;
final String type;
final String format;
final String identifier;
@@ -51,9 +52,9 @@ class DublinCore {
subject: findElementOrNull(element, "dc:subject")?.text,
publisher: findElementOrNull(element, "dc:publisher")?.text,
contributor: findElementOrNull(element, "dc:contributor")?.text,
date: findElementOrNull(element, "dc:date")?.text,
created: findElementOrNull(element, "dc:created")?.text,
modified: findElementOrNull(element, "dc:modified")?.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,


+ 1
- 1
pubspec.yaml Прегледај датотеку

@@ -1,5 +1,5 @@
name: webfeed
version: 0.4.3
version: 0.4.2
description: webfeed is a dart package for parsing RSS and Atom feeds. Media & DublinCore namespaces are also supported.
author: Wito Chandra <wito.c.91@gmail.com>
homepage: https://github.com/witochandra/webfeed


+ 10
- 9
test/rss_test.dart Прегледај датотеку

@@ -2,10 +2,9 @@ import 'dart:core';
import 'dart:io';

import 'package:test/test.dart';
import 'package:webfeed/webfeed.dart';

import 'package:webfeed/domain/rss_itunes_type.dart';
import 'package:webfeed/domain/rss_itunes_episode_type.dart';
import 'package:webfeed/domain/rss_itunes_type.dart';
import 'package:webfeed/webfeed.dart';

void main() {
test("parse Invalid.xml", () {
@@ -72,7 +71,8 @@ void main() {
"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.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");
@@ -102,7 +102,8 @@ void main() {
var item = feed.items.first;
expect(item.title, null);
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.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);
@@ -239,9 +240,9 @@ void main() {
expect(feed.dc.description, "description");
expect(feed.dc.publisher, "publisher");
expect(feed.dc.contributor, "contributor");
expect(feed.dc.date, "2000-01-01T12:00+00:00");
expect(feed.dc.created, "2000-01-01T12:00+00:00");
expect(feed.dc.modified, "2000-01-01T12:00+00:00");
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");
@@ -257,7 +258,7 @@ void main() {
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, "2000-01-01T12:00+00:00");
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");


+ 2
- 2
test/xml/RSS-DC.xml Прегледај датотеку

@@ -25,8 +25,8 @@
<dc:publisher>publisher</dc:publisher>
<dc:contributor>contributor</dc:contributor>
<dc:date>2000-01-01T12:00+00:00</dc:date>
<dc:created>2000-01-01T12:00+00:00</dc:created>
<dc:modified>2000-01-01T12:00+00:00</dc:modified>
<dc:created>2000-01-01T13:00+00:00</dc:created>
<dc:modified>2000-01-01T14:00+00:00</dc:modified>
<dc:type>type</dc:type>
<dc:format>format</dc:format>
<dc:identifier>identifier</dc:identifier>


Loading…
Откажи
Сачувај