| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |