| 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('hosted_source'); | 5 #library('hosted_source'); |
| 6 | 6 |
| 7 #import('dart:io', prefix: 'io'); | 7 #import('dart:io', prefix: 'io'); |
| 8 #import('dart:json'); | 8 #import('dart:json'); |
| 9 #import('dart:uri'); | 9 #import('dart:uri'); |
| 10 | 10 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 } | 89 } |
| 90 | 90 |
| 91 /** | 91 /** |
| 92 * The system cache directory for the hosted source contains subdirectories | 92 * The system cache directory for the hosted source contains subdirectories |
| 93 * for each separate repository URL that's used on the system. Each of these | 93 * for each separate repository URL that's used on the system. Each of these |
| 94 * subdirectories then contains a subdirectory for each package installed | 94 * subdirectories then contains a subdirectory for each package installed |
| 95 * from that site. | 95 * from that site. |
| 96 */ | 96 */ |
| 97 String systemCacheDirectory(PackageId id) { | 97 String systemCacheDirectory(PackageId id) { |
| 98 var parsed = _parseDescription(id.description); | 98 var parsed = _parseDescription(id.description); |
| 99 var url = parsed.last.replaceAll(new RegExp(@"^https?://"), ""); | 99 var url = parsed.last.replaceAll(new RegExp(r"^https?://"), ""); |
| 100 var urlDir = replace(url, new RegExp(@'[<>:"\\/|?*%]'), (match) { | 100 var urlDir = replace(url, new RegExp(r'[<>:"\\/|?*%]'), (match) { |
| 101 return '%${match[0].charCodeAt(0)}'; | 101 return '%${match[0].charCodeAt(0)}'; |
| 102 }); | 102 }); |
| 103 return join(systemCacheRoot, urlDir, "${parsed.first}-${id.version}"); | 103 return join(systemCacheRoot, urlDir, "${parsed.first}-${id.version}"); |
| 104 } | 104 } |
| 105 | 105 |
| 106 String packageName(description) => _parseDescription(description).first; | 106 String packageName(description) => _parseDescription(description).first; |
| 107 | 107 |
| 108 bool descriptionsEqual(description1, description2) => | 108 bool descriptionsEqual(description1, description2) => |
| 109 _parseDescription(description1) == _parseDescription(description2); | 109 _parseDescription(description1) == _parseDescription(description2); |
| 110 | 110 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 142 |
| 143 var name = description["name"]; | 143 var name = description["name"]; |
| 144 if (name is! String) { | 144 if (name is! String) { |
| 145 throw new FormatException("The 'name' key must have a string value."); | 145 throw new FormatException("The 'name' key must have a string value."); |
| 146 } | 146 } |
| 147 | 147 |
| 148 var url = description.containsKey("url") ? description["url"] : defaultUrl; | 148 var url = description.containsKey("url") ? description["url"] : defaultUrl; |
| 149 return new Pair<String, String>(name, url); | 149 return new Pair<String, String>(name, url); |
| 150 } | 150 } |
| 151 } | 151 } |
| OLD | NEW |