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

Unified Diff: utils/pub/repo_source.dart

Issue 10704172: Hook in the version solver to pub install. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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/pubspec.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/repo_source.dart
diff --git a/utils/pub/repo_source.dart b/utils/pub/repo_source.dart
index 42b95960761cd7d3217ea2c74498ce8531f23462..1046af7ae44b23734446b647b65203d51cd1ebf3 100644
--- a/utils/pub/repo_source.dart
+++ b/utils/pub/repo_source.dart
@@ -5,11 +5,15 @@
#library('dartlang_source');
#import('dart:io');
+#import('dart:json');
#import('dart:uri');
#import('io.dart');
#import('package.dart');
+#import('pubspec.dart');
#import('source.dart');
+#import('source_registry.dart');
#import('utils.dart');
+#import('version.dart');
/**
* A package source that installs packages from a package repository that uses
@@ -32,6 +36,33 @@ class RepoSource extends Source {
RepoSource();
/**
+ * Downloads a list of all versions of a package that have been uploaded to
+ * pub.dartlang.org.
+ */
+ Future<List<Version>> getVersions(description) {
+ var parsed = _parseDescription(description);
+ var fullUrl = "${parsed.last}/packages/${parsed.first}.json";
+ return consumeInputStream(httpGet(fullUrl)).transform((data) {
+ var doc = JSON.parse(new String.fromCharCodes(data));
+ return doc['versions'].map((version) => new Version.parse(version));
+ });
+ }
+
+ /**
+ * Downloads and parses the pubspec for a specific version of a package that
+ * has been uploaded to pub.dartlang.org.
+ */
+ Future<Pubspec> describe(PackageId id) {
+ var parsed = _parseDescription(id.description);
+ var fullUrl = "${parsed.last}/packages/${parsed.first}/versions/"
+ "${id.version}.yaml";
+ return consumeInputStream(httpGet(fullUrl)).transform((data) {
+ return new Pubspec.parse(
+ new String.fromCharCodes(data), systemCache.sources);
+ });
+ }
+
+ /**
* Downloads a package from a package repository and unpacks it.
*/
Future<bool> install(PackageId id, String destPath) {
« no previous file with comments | « utils/pub/pubspec.dart ('k') | utils/pub/sdk_source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698