Replace paresPubspec top-level function with Pubspec.parse ctor
diff --git a/pkgs/pubspec_parse/lib/pubspec_parse.dart b/pkgs/pubspec_parse/lib/pubspec_parse.dart
index 3339982..99886c4 100644
--- a/pkgs/pubspec_parse/lib/pubspec_parse.dart
+++ b/pkgs/pubspec_parse/lib/pubspec_parse.dart
@@ -10,5 +10,4 @@
         SdkDependency,
         PathDependency;
 export 'src/errors.dart' show ParsedYamlException;
-export 'src/functions.dart' show parsePubspec;
 export 'src/pubspec.dart' show Pubspec;
diff --git a/pkgs/pubspec_parse/lib/src/functions.dart b/pkgs/pubspec_parse/lib/src/functions.dart
deleted file mode 100644
index 84ef35c..0000000
--- a/pkgs/pubspec_parse/lib/src/functions.dart
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'package:json_annotation/json_annotation.dart';
-import 'package:yaml/yaml.dart';
-
-import 'errors.dart';
-import 'pubspec.dart';
-
-/// If [sourceUrl] is passed, it's used as the URL from which the YAML
-/// originated for error reporting. It can be a [String], a [Uri], or `null`.
-Pubspec parsePubspec(String yaml, {sourceUrl}) {
-  var item = loadYaml(yaml, sourceUrl: sourceUrl);
-
-  if (item == null) {
-    throw new ArgumentError.notNull('yaml');
-  }
-
-  if (item is! YamlMap) {
-    if (item is YamlNode) {
-      throw parsedYamlException('Does not represent a YAML map.', item);
-    }
-
-    throw new ArgumentError.value(
-        yaml, 'yaml', 'Does not represent a YAML map.');
-  }
-
-  try {
-    return new Pubspec.fromJson(item as YamlMap);
-  } on CheckedFromJsonException catch (error, stack) {
-    throw parsedYamlExceptionFromError(error, stack);
-  }
-}
diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart
index 163f3f9..b578596 100644
--- a/pkgs/pubspec_parse/lib/src/pubspec.dart
+++ b/pkgs/pubspec_parse/lib/src/pubspec.dart
@@ -4,6 +4,7 @@
 
 import 'package:json_annotation/json_annotation.dart';
 import 'package:pub_semver/pub_semver.dart';
+import 'package:yaml/yaml.dart';
 
 import 'dependency.dart';
 import 'errors.dart';
@@ -75,6 +76,29 @@
 
   factory Pubspec.fromJson(Map json) => _$PubspecFromJson(json);
 
+  factory Pubspec.parse(String yaml, {sourceUrl}) {
+    var item = loadYaml(yaml, sourceUrl: sourceUrl);
+
+    if (item == null) {
+      throw new ArgumentError.notNull('yaml');
+    }
+
+    if (item is! YamlMap) {
+      if (item is YamlNode) {
+        throw parsedYamlException('Does not represent a YAML map.', item);
+      }
+
+      throw new ArgumentError.value(
+          yaml, 'yaml', 'Does not represent a YAML map.');
+    }
+
+    try {
+      return new Pubspec.fromJson(item as YamlMap);
+    } on CheckedFromJsonException catch (error, stack) {
+      throw parsedYamlExceptionFromError(error, stack);
+    }
+  }
+
   static List<String> _normalizeAuthors(String author, List<String> authors) {
     var value = new Set<String>();
     if (author != null) {
diff --git a/pkgs/pubspec_parse/test/test_utils.dart b/pkgs/pubspec_parse/test/test_utils.dart
index 69102bf..0924b41 100644
--- a/pkgs/pubspec_parse/test/test_utils.dart
+++ b/pkgs/pubspec_parse/test/test_utils.dart
@@ -49,7 +49,7 @@
 Pubspec parse(Object content, {bool quietOnError: false}) {
   quietOnError ??= false;
   try {
-    return parsePubspec(_encodeJson(content));
+    return new Pubspec.parse(_encodeJson(content));
   } on ParsedYamlException catch (e) {
     if (!quietOnError) {
       _printDebugParsedYamlException(e);