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

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

Issue 11414069: Make mappedBy lazy. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Reupload due to error. Created 8 years, 1 month 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
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 22 matching lines...) Expand all
33 /** 33 /**
34 * Downloads a list of all versions of a package that are available from the 34 * Downloads a list of all versions of a package that are available from the
35 * site. 35 * site.
36 */ 36 */
37 Future<List<Version>> getVersions(String name, description) { 37 Future<List<Version>> getVersions(String name, description) {
38 var parsed = _parseDescription(description); 38 var parsed = _parseDescription(description);
39 var fullUrl = "${parsed.last}/packages/${parsed.first}.json"; 39 var fullUrl = "${parsed.last}/packages/${parsed.first}.json";
40 40
41 return httpGetString(fullUrl).transform((body) { 41 return httpGetString(fullUrl).transform((body) {
42 var doc = json.parse(body); 42 var doc = json.parse(body);
43 return doc['versions'].mappedBy((version) => new Version.parse(version)); 43 return doc['versions']
44 .mappedBy((version) => new Version.parse(version))
45 .toList();
44 }).transformException((ex) { 46 }).transformException((ex) {
45 _throwFriendlyError(ex, parsed.first, parsed.last); 47 _throwFriendlyError(ex, parsed.first, parsed.last);
46 }); 48 });
47 } 49 }
48 50
49 /** 51 /**
50 * Downloads and parses the pubspec for a specific version of a package that 52 * Downloads and parses the pubspec for a specific version of a package that
51 * is available from the site. 53 * is available from the site.
52 */ 54 */
53 Future<Pubspec> describe(PackageId id) { 55 Future<Pubspec> describe(PackageId id) {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 166
165 var name = description["name"]; 167 var name = description["name"];
166 if (name is! String) { 168 if (name is! String) {
167 throw new FormatException("The 'name' key must have a string value."); 169 throw new FormatException("The 'name' key must have a string value.");
168 } 170 }
169 171
170 var url = description.containsKey("url") ? description["url"] : defaultUrl; 172 var url = description.containsKey("url") ? description["url"] : defaultUrl;
171 return new Pair<String, String>(name, url); 173 return new Pair<String, String>(name, url);
172 } 174 }
173 } 175 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698