Chromium Code Reviews| Index: utils/pub/pubspec.dart |
| diff --git a/utils/pub/pubspec.dart b/utils/pub/pubspec.dart |
| index 779a29490dde802ead5d07764cc71451c645ca62..fac89ebb8b774ab24d66857c7920eb32a33826f8 100644 |
| --- a/utils/pub/pubspec.dart |
| +++ b/utils/pub/pubspec.dart |
| @@ -38,7 +38,8 @@ class Pubspec { |
| if (!fileExists(pubspecPath)) throw new PubspecNotFoundException(name); |
| try { |
| - var pubspec = new Pubspec.parse(readTextFile(pubspecPath), sources); |
| + var pubspec = new Pubspec.parse(pubspecPath, readTextFile(pubspecPath), |
| + sources); |
| if (pubspec.name == null) { |
| throw new PubspecHasNoNameException(name); |
| @@ -69,10 +70,12 @@ class Pubspec { |
| bool get isEmpty => |
| name == null && version == Version.none && dependencies.isEmpty; |
| - // TODO(rnystrom): Make this a static method to match corelib. |
| - /// Parses the pubspec whose text is [contents]. If the pubspec doesn't define |
| - /// version for itself, it defaults to [Version.none]. |
| - factory Pubspec.parse(String contents, SourceRegistry sources) { |
| + /// Parses the pubspec stored at [filePath] whose text is [contents]. If the |
| + /// pubspec doesn't define version for itself, it defaults to [Version.none]. |
| + /// [filePath] may be `null` if the pubspec is not on the user's local |
| + /// file system. |
| + factory Pubspec.parse(String filePath, String contents, |
|
nweiz
2013/02/19 19:30:51
It would be nice to separate out Pubspec.parse and
Bob Nystrom
2013/02/19 19:49:34
Good idea. Added a TODO.
|
| + SourceRegistry sources) { |
| var name = null; |
| var version = Version.none; |
| @@ -97,7 +100,7 @@ class Pubspec { |
| version = new Version.parse(parsedPubspec['version']); |
| } |
| - var dependencies = _parseDependencies(sources, |
| + var dependencies = _parseDependencies(filePath, sources, |
| parsedPubspec['dependencies']); |
| var environmentYaml = parsedPubspec['environment']; |
| @@ -187,7 +190,8 @@ void _validateFieldUrl(url, String field) { |
| } |
| } |
| -List<PackageRef> _parseDependencies(SourceRegistry sources, yaml) { |
| +List<PackageRef> _parseDependencies(String pubspecPath, SourceRegistry sources, |
| + yaml) { |
| var dependencies = <PackageRef>[]; |
| // Allow an empty dependencies key. |
| @@ -233,7 +237,8 @@ List<PackageRef> _parseDependencies(SourceRegistry sources, yaml) { |
| 'Dependency specification $spec should be a string or a mapping.'); |
| } |
| - source.validateDescription(description, fromLockFile: false); |
| + description = source.parseDescription(pubspecPath, description, |
| + fromLockFile: false); |
| dependencies.add(new PackageRef( |
| name, source, versionConstraint, description)); |