Ver a proveniência

reformat code

master
Wito Chandra há 8 anos
ascendente
cometimento
c2b251797f
15 ficheiros alterados com 86 adições e 27 eliminações
  1. +37
    -0
      analysis_options.yaml
  2. +1
    -2
      example/main.dart
  3. +1
    -1
      lib/domain/atom_category.dart
  4. +11
    -3
      lib/domain/atom_feed.dart
  5. +1
    -1
      lib/domain/atom_generator.dart
  6. +1
    -1
      lib/domain/atom_item.dart
  7. +1
    -1
      lib/domain/atom_link.dart
  8. +2
    -2
      lib/domain/atom_person.dart
  9. +1
    -1
      lib/domain/atom_source.dart
  10. +2
    -2
      lib/domain/rss_category.dart
  11. +5
    -5
      lib/domain/rss_feed.dart
  12. +1
    -1
      lib/domain/rss_item.dart
  13. +13
    -0
      lib/webfeed.dart
  14. +6
    -5
      test/atom_test.dart
  15. +3
    -2
      test/rss_test.dart

+ 37
- 0
analysis_options.yaml Ver ficheiro

@@ -0,0 +1,37 @@
analyzer:
language:
enablePreviewDart2: true
strong-mode: true
errors:
unused_import: error
unused_local_variable: error
dead_code: error
linter:
rules:
# Errors
- avoid_empty_else
- comment_references
- control_flow_in_finally
- empty_statements
- hash_and_equals
- test_types_in_equals
- throw_in_finally
- unrelated_type_equality_checks
- valid_regexps

# Style
- avoid_init_to_null
- avoid_return_types_on_setters
- await_only_futures
- camel_case_types
- directives_ordering
- empty_constructor_bodies
- library_names
- library_prefixes
- non_constant_identifier_names
- omit_local_variable_types
- prefer_final_fields
- prefer_is_not_empty
- prefer_typing_uninitialized_variables
- slash_for_doc_comments
- type_init_formals

+ 1
- 2
example/main.dart Ver ficheiro

@@ -1,6 +1,5 @@
import 'package:http/http.dart' as http;
import 'package:webfeed/domain/atom_feed.dart';
import 'package:webfeed/domain/rss_feed.dart';
import 'package:webfeed/webfeed.dart';

void main() {
var client = new http.Client();


+ 1
- 1
lib/domain/atom_category.dart Ver ficheiro

@@ -22,4 +22,4 @@ class AtomCategory {
label: $label
''';
}
}
}

+ 11
- 3
lib/domain/atom_feed.dart Ver ficheiro

@@ -3,8 +3,8 @@ import 'package:webfeed/domain/atom_generator.dart';
import 'package:webfeed/domain/atom_item.dart';
import 'package:webfeed/domain/atom_link.dart';
import 'package:webfeed/domain/atom_person.dart';
import 'package:xml/xml.dart';
import 'package:webfeed/util/helpers.dart';
import 'package:xml/xml.dart';

class AtomFeed {
String id;
@@ -23,7 +23,15 @@ class AtomFeed {
String subtitle;

AtomFeed(this.id, this.title, this.updated, this.items,
{this.links, this.authors, this.contributors, this.categories, this.generator, this.icon, this.logo, this.rights, this.subtitle});
{this.links,
this.authors,
this.contributors,
this.categories,
this.generator,
this.icon,
this.logo,
this.rights,
this.subtitle});

factory AtomFeed.parse(String xmlString) {
var document = parse(xmlString);
@@ -36,7 +44,7 @@ class AtomFeed {
var id = xmlGetString(feedElement, "id");
var title = xmlGetString(feedElement, "title");
var updated = xmlGetString(feedElement, "updated");
var items = feedElement.findElements("entry").map((element) {
return new AtomItem.parse(element);
}).toList();


+ 1
- 1
lib/domain/atom_generator.dart Ver ficheiro

@@ -22,4 +22,4 @@ class AtomGenerator {
value: $value
''';
}
}
}

+ 1
- 1
lib/domain/atom_item.dart Ver ficheiro

@@ -2,8 +2,8 @@ import 'package:webfeed/domain/atom_category.dart';
import 'package:webfeed/domain/atom_link.dart';
import 'package:webfeed/domain/atom_person.dart';
import 'package:webfeed/domain/atom_source.dart';
import 'package:xml/xml.dart';
import 'package:webfeed/util/helpers.dart';
import 'package:xml/xml.dart';

class AtomItem {
String id;


+ 1
- 1
lib/domain/atom_link.dart Ver ficheiro

@@ -34,4 +34,4 @@ class AtomLink {
length: $length
''';
}
}
}

+ 2
- 2
lib/domain/atom_person.dart Ver ficheiro

@@ -1,5 +1,5 @@
import 'package:xml/xml.dart';
import 'package:webfeed/util/helpers.dart';
import 'package:xml/xml.dart';

class AtomPerson {
String name;
@@ -23,4 +23,4 @@ class AtomPerson {
email: $email
''';
}
}
}

+ 1
- 1
lib/domain/atom_source.dart Ver ficheiro

@@ -24,4 +24,4 @@ class AtomSource {
updated: $updated
''';
}
}
}

+ 2
- 2
lib/domain/rss_category.dart Ver ficheiro

@@ -7,8 +7,8 @@ class RssCategory {
RssCategory(this.domain, this.value);

factory RssCategory.parse(XmlElement node) {
String domain = node.getAttribute("domain");
String value = node.text;
var domain = node.getAttribute("domain");
var value = node.text;

return new RssCategory(domain, value);
}


+ 5
- 5
lib/domain/rss_feed.dart Ver ficheiro

@@ -45,7 +45,7 @@ class RssFeed {
this.ttl});

factory RssFeed.parse(String xmlString) {
XmlDocument document = parse(xmlString);
var document = parse(xmlString);
XmlElement channelElement;
try {
channelElement = document.findAllElements("channel").first;
@@ -56,7 +56,7 @@ class RssFeed {
var description = xmlGetString(channelElement, "description");
var link = xmlGetString(channelElement, "link");

List<RssItem> feeds = channelElement.findElements("item").map((element) {
var feeds = channelElement.findElements("item").map((element) {
return new RssItem.parse(element);
}).toList();

@@ -70,18 +70,18 @@ class RssFeed {
cloud = new RssCloud.parse(channelElement.findElements("cloud").first);
} on StateError {}

List<RssCategory> categories = channelElement.findElements("category").map((element) {
var categories = channelElement.findElements("category").map((element) {
return new RssCategory.parse(element);
}).toList();

List<String> skipDays = new List<String>();
var skipDays = new List<String>();
var skipDaysNodes = channelElement.findElements("skipDays");
if (skipDaysNodes.isNotEmpty) {
skipDays = skipDaysNodes.first.findAllElements("day").map((element) {
return element.text;
}).toList();
}
List<int> skipHours = new List<int>();
var skipHours = new List<int>();
var skipHoursNodes = channelElement.findElements("skipHours");
if (skipHoursNodes.isNotEmpty) {
skipHours = skipHoursNodes.first.findAllElements("hour").map((element) {


+ 1
- 1
lib/domain/rss_item.dart Ver ficheiro

@@ -23,7 +23,7 @@ class RssItem {
var description = xmlGetString(element, "description");
var link = xmlGetString(element, "link");

List<RssCategory> categories = element.findElements("category").map((element) {
var categories = element.findElements("category").map((element) {
return new RssCategory.parse(element);
}).toList();



+ 13
- 0
lib/webfeed.dart Ver ficheiro

@@ -0,0 +1,13 @@
export 'domain/atom_category.dart';
export 'domain/atom_feed.dart';
export 'domain/atom_generator.dart';
export 'domain/atom_item.dart';
export 'domain/atom_link.dart';
export 'domain/atom_person.dart';
export 'domain/atom_source.dart';
export 'domain/rss_category.dart';
export 'domain/rss_cloud.dart';
export 'domain/rss_feed.dart';
export 'domain/rss_image.dart';
export 'domain/rss_item.dart';
export 'domain/rss_source.dart';

+ 6
- 5
test/atom_test.dart Ver ficheiro

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

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

void main() {
test("parsing Invalid.xml", () {
@@ -12,7 +13,7 @@ void main() {
fail("Should throw Argument Error");
} on ArgumentError {}
});
test("parsing Atom.xml", () {
var xmlString = new File("test/xml/Atom.xml").readAsStringSync();

@@ -71,7 +72,7 @@ void main() {
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");
@@ -87,4 +88,4 @@ void main() {
expect(item.content, "This is content 1");
expect(item.rights, "This is rights 1");
});
}
}

+ 3
- 2
test/rss_test.dart Ver ficheiro

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

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

void main() {
test("parsing Invalid.xml", () {


Carregando…
Cancelar
Guardar