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

Side by Side Diff: utils/pub/hosted_source.dart

Issue 11785028: Commit Martin's patch for pub + lib_v2. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « utils/pub/command_version.dart ('k') | utils/pub/http.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library hosted_source; 5 library hosted_source;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io' as io; 8 import 'dart:io' as io;
9 import 'dart:json' as json; 9 import 'dart:json' as json;
10 import 'dart:uri'; 10 import 'dart:uri';
(...skipping 23 matching lines...) Expand all
34 /// site. 34 /// site.
35 Future<List<Version>> getVersions(String name, description) { 35 Future<List<Version>> getVersions(String name, description) {
36 var parsed = _parseDescription(description); 36 var parsed = _parseDescription(description);
37 var fullUrl = "${parsed.last}/packages/${parsed.first}.json"; 37 var fullUrl = "${parsed.last}/packages/${parsed.first}.json";
38 38
39 return httpClient.read(fullUrl).then((body) { 39 return httpClient.read(fullUrl).then((body) {
40 var doc = json.parse(body); 40 var doc = json.parse(body);
41 return doc['versions'] 41 return doc['versions']
42 .mappedBy((version) => new Version.parse(version)) 42 .mappedBy((version) => new Version.parse(version))
43 .toList(); 43 .toList();
44 }).transformException((ex) { 44 }).catchError((ex) {
45 _throwFriendlyError(ex, parsed.first, parsed.last); 45 _throwFriendlyError(ex, parsed.first, parsed.last);
46 }); 46 });
47 } 47 }
48 48
49 /// Downloads and parses the pubspec for a specific version of a package that 49 /// Downloads and parses the pubspec for a specific version of a package that
50 /// is available from the site. 50 /// is available from the site.
51 Future<Pubspec> describe(PackageId id) { 51 Future<Pubspec> describe(PackageId id) {
52 var parsed = _parseDescription(id.description); 52 var parsed = _parseDescription(id.description);
53 var fullUrl = "${parsed.last}/packages/${parsed.first}/versions/" 53 var fullUrl = "${parsed.last}/packages/${parsed.first}/versions/"
54 "${id.version}.yaml"; 54 "${id.version}.yaml";
55 55
56 return httpClient.read(fullUrl).then((yaml) { 56 return httpClient.read(fullUrl).then((yaml) {
57 return new Pubspec.parse(yaml, systemCache.sources); 57 return new Pubspec.parse(yaml, systemCache.sources);
58 }).transformException((ex) { 58 }).catchError((ex) {
59 _throwFriendlyError(ex, id, parsed.last); 59 _throwFriendlyError(ex, id, parsed.last);
60 }); 60 });
61 } 61 }
62 62
63 /// Downloads a package from the site and unpacks it. 63 /// Downloads a package from the site and unpacks it.
64 Future<bool> install(PackageId id, String destPath) { 64 Future<bool> install(PackageId id, String destPath) {
65 var parsedDescription = _parseDescription(id.description); 65 var parsedDescription = _parseDescription(id.description);
66 var name = parsedDescription.first; 66 var name = parsedDescription.first;
67 var url = parsedDescription.last; 67 var url = parsedDescription.last;
68 68
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 157
158 var name = description["name"]; 158 var name = description["name"];
159 if (name is! String) { 159 if (name is! String) {
160 throw new FormatException("The 'name' key must have a string value."); 160 throw new FormatException("The 'name' key must have a string value.");
161 } 161 }
162 162
163 var url = description.containsKey("url") ? description["url"] : defaultUrl; 163 var url = description.containsKey("url") ? description["url"] : defaultUrl;
164 return new Pair<String, String>(name, url); 164 return new Pair<String, String>(name, url);
165 } 165 }
166 } 166 }
OLDNEW
« no previous file with comments | « utils/pub/command_version.dart ('k') | utils/pub/http.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698