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

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

Issue 10690032: Make VersionSolver source- and description-aware. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « utils/pub/pubspec.dart ('k') | utils/pub/root_source.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('dartlang_source'); 5 #library('dartlang_source');
6 6
7 #import('dart:io'); 7 #import('dart:io');
8 #import('dart:uri'); 8 #import('dart:uri');
9 #import('io.dart'); 9 #import('io.dart');
10 #import('package.dart'); 10 #import('package.dart');
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 */ 53 */
54 String systemCacheDirectory(PackageId id, String parent) { 54 String systemCacheDirectory(PackageId id, String parent) {
55 var parsed = _parseDescription(id.description); 55 var parsed = _parseDescription(id.description);
56 var url = parsed.last.replaceAll(new RegExp(@"^https?://"), ""); 56 var url = parsed.last.replaceAll(new RegExp(@"^https?://"), "");
57 var urlDir = replace(url, new RegExp(@'[<>:"\\/|?*%]'), (match) { 57 var urlDir = replace(url, new RegExp(@'[<>:"\\/|?*%]'), (match) {
58 return '%${match[0].charCodeAt(0)}'; 58 return '%${match[0].charCodeAt(0)}';
59 }); 59 });
60 return join(parent, urlDir, "${parsed.first}-${id.version}"); 60 return join(parent, urlDir, "${parsed.first}-${id.version}");
61 } 61 }
62 62
63 String packageName(PackageId id) => _parseDescription(id.description).first; 63 String packageName(description) => _parseDescription(description).first;
64
65 bool descriptionsEqual(description1, description2) =>
66 _parseDescription(description1) == _parseDescription(description2);
64 67
65 /** 68 /**
66 * Ensures that [description] is a valid repo description. 69 * Ensures that [description] is a valid repo description.
67 * 70 *
68 * There are two valid formats. A plain string refers to a package with the 71 * There are two valid formats. A plain string refers to a package with the
69 * given name from the default repository, while a map with keys "name" and 72 * given name from the default repository, while a map with keys "name" and
70 * "url" refers to a package with the given name from the repo at the given 73 * "url" refers to a package with the given name from the repo at the given
71 * URL. 74 * URL.
72 */ 75 */
73 void validateDescription(description) { 76 void validateDescription(description) {
(...skipping 23 matching lines...) Expand all
97 100
98 var name = description["name"]; 101 var name = description["name"];
99 if (name is! String) { 102 if (name is! String) {
100 throw new FormatException("The 'name' key must have a string value."); 103 throw new FormatException("The 'name' key must have a string value.");
101 } 104 }
102 105
103 var url = description.containsKey("url") ? description["url"] : defaultUrl; 106 var url = description.containsKey("url") ? description["url"] : defaultUrl;
104 return new Pair<String, String>(name, url); 107 return new Pair<String, String>(name, url);
105 } 108 }
106 } 109 }
OLDNEW
« no previous file with comments | « utils/pub/pubspec.dart ('k') | utils/pub/root_source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698