Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Unified Diff: utils/pub/pubspec.dart

Issue 10874051: Support self-referential package: imports with Pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review change Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « utils/pub/package.dart ('k') | utils/pub/sdk_source.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/pubspec.dart
diff --git a/utils/pub/pubspec.dart b/utils/pub/pubspec.dart
index e18b89b1439e994a3d23c839c1e803c6053cd292..2b82a71acb76f4da67a83adda9a3d9865fbb724c 100644
--- a/utils/pub/pubspec.dart
+++ b/utils/pub/pubspec.dart
@@ -16,6 +16,11 @@
*/
class Pubspec {
/**
+ * This package's name.
+ */
+ final String name;
+
+ /**
* This package's version.
*/
final Version version;
@@ -25,17 +30,23 @@ class Pubspec {
*/
List<PackageRef> dependencies;
- Pubspec(this.version, this.dependencies);
+ Pubspec(this.name, this.version, this.dependencies);
Pubspec.empty()
- : version = Version.none,
+ : name = null,
+ version = Version.none,
dependencies = <PackageRef>[];
+ /** Whether or not the pubspec has no contents. */
+ bool get isEmpty() =>
+ name == null && version == Version.none && dependencies.isEmpty();
+
/**
* 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) {
+ var name = null;
var version = Version.none;
var dependencies = <PackageRef>[];
@@ -48,6 +59,8 @@ class Pubspec {
throw new FormatException('The pubspec must be a YAML mapping.');
}
+ if (parsedPubspec.containsKey('name')) name = parsedPubspec['name'];
+
if (parsedPubspec.containsKey('version')) {
version = new Version.parse(parsedPubspec['version']);
}
@@ -102,6 +115,6 @@ class Pubspec {
});
}
- return new Pubspec(version, dependencies);
+ return new Pubspec(name, version, dependencies);
}
}
« no previous file with comments | « utils/pub/package.dart ('k') | utils/pub/sdk_source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698