Remove services requiring XML parsing
Not exposed via a regular API - likely fragile
MODIFY
lib/src/common.dart
lib/src/common.dart
@@ -9,7 +9,6 @@ import "dart:convert"
import "package:http/http.dart" as http;
import 'package:http_parser/http_parser.dart' as http_parser;
import "package:json_annotation/json_annotation.dart";
-import "package:xml/xml.dart" as xml;
import 'common/model/users.dart';
import "common/util/pagination.dart";
@@ -21,7 +20,6 @@ export "common/util/pagination.dart";
part "common.g.dart";
part "common/activity_service.dart";
part "common/authorizations_service.dart";
-part "common/blog_service.dart";
part "common/gists_service.dart";
part "common/git_service.dart";
part "common/github.dart";
@@ -29,7 +27,6 @@ part "common/issues_service.dart";
part "common/misc_service.dart";
part "common/model/activity.dart";
part "common/model/authorizations.dart";
-part "common/model/blog.dart";
part "common/model/gists.dart";
part "common/model/git.dart";
part "common/model/issues.dart";

DELETE
lib/src/common/blog_service.dart
-part of github.common;
-
-/// The [BlogService] provides methods to retrieve blog posts from GitHub.
-class BlogService extends Service {
- BlogService(GitHub github) : super(github);
-
- /// Returns a stream of blog posts for the specified [url].
- Stream<BlogPost> listPosts([String url = "https://github.com/blog.atom"]) {
- var controller = new StreamController<BlogPost>();
- _github.client.get(url).then((response) {
- var document = xml.parse(response.body);
-
- var entries = document.rootElement.findElements("entry");
-
- for (var entry in entries) {
- controller.add(BlogPost.fromXML(entry));
- }
-
- controller.close();
- });
-
- return controller.stream;
- }
-}

MODIFY
lib/src/common/github.dart
lib/src/common/github.dart
@@ -25,7 +25,6 @@ class GitHub {
ActivityService _activity;
AuthorizationsService _authorizations;
- BlogService _blog;
GistsService _gists;
GitService _git;
IssuesService _issues;
@@ -94,14 +93,6 @@ class GitHub {
return _authorizations;
}
- /// Service to retrieve blog posts.
- BlogService get blog {
- if (_blog == null) {
- _blog = new BlogService(this);
- }
- return _blog;
- }
-
/// Service for gist related methods of the GitHub API.
GistsService get gists {
if (_gists == null) {

DELETE
lib/src/common/model/blog.dart
-part of github.common;
-
-/// Model class for a blog post.
-class BlogPost {
- DateTime publishedAt;
- DateTime updatedAt;
-
- String title;
- String url;
- String category;
- String content;
- String author;
-
- static BlogPost fromXML(xml.XmlElement node) {
- var children = node.children;
-
- xml.XmlElement query(String tagName) => children
- .firstWhere((it) => it is xml.XmlElement && it.name.local == tagName);
-
- var title = query("title").text;
- var content = query("content").text;
- var link = query("link").getAttribute("href");
- var category = query("category").text;
- var author = query("author").children[0].text;
-
- var post = new BlogPost();
-
- post.author = author;
- post.title = title;
- post.content = content;
- post.category = category;
- post.url = link;
-
- return post;
- }
-}

MODIFY
pubspec.yaml
pubspec.yaml
@@ -9,7 +9,6 @@ dependencies:
http: '>=0.11.3 <0.13.0'
http_parser: ^3.1.1
json_annotation: ^1.1.0
- xml: '>=2.0.0 <4.0.0'
dev_dependencies:
build_runner: ^0.10.0
json_serializable: ^1.1.0

DELETE
test/experiment/blog.dart
-import "package:github/server.dart";
-
-void main() {
- var github = createGitHubClient();
-
- github.blog.listPosts().listen((post) {
- print(post.title);
- }).onDone(() => github.dispose());
-}

Remove services requiring XML parsing

Not exposed via a regular API - likely fragile