| 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: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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Future<String> systemCacheDirectory(PackageId id) { | 96 Future<String> systemCacheDirectory(PackageId id) { |
| 97 var parsed = _parseDescription(id.description); | 97 var parsed = _parseDescription(id.description); |
| 98 var url = parsed.last.replaceAll(new RegExp(r"^https?://"), ""); | 98 var url = parsed.last.replaceAll(new RegExp(r"^https?://"), ""); |
| 99 var urlDir = replace(url, new RegExp(r'[<>:"\\/|?*%]'), (match) { | 99 var urlDir = replace(url, new RegExp(r'[<>:"\\/|?*%]'), (match) { |
| 100 return '%${match[0].charCodeAt(0)}'; | 100 return '%${match[0].codeUnitAt(0)}'; |
| 101 }); | 101 }); |
| 102 | 102 |
| 103 return new Future.immediate( | 103 return new Future.immediate( |
| 104 path.join(systemCacheRoot, urlDir, "${parsed.first}-${id.version}")); | 104 path.join(systemCacheRoot, urlDir, "${parsed.first}-${id.version}")); |
| 105 } | 105 } |
| 106 | 106 |
| 107 String packageName(description) => _parseDescription(description).first; | 107 String packageName(description) => _parseDescription(description).first; |
| 108 | 108 |
| 109 bool descriptionsEqual(description1, description2) => | 109 bool descriptionsEqual(description1, description2) => |
| 110 _parseDescription(description1) == _parseDescription(description2); | 110 _parseDescription(description1) == _parseDescription(description2); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 | 161 |
| 162 var name = description["name"]; | 162 var name = description["name"]; |
| 163 if (name is! String) { | 163 if (name is! String) { |
| 164 throw new FormatException("The 'name' key must have a string value."); | 164 throw new FormatException("The 'name' key must have a string value."); |
| 165 } | 165 } |
| 166 | 166 |
| 167 var url = description.containsKey("url") ? description["url"] : defaultUrl; | 167 var url = description.containsKey("url") ? description["url"] : defaultUrl; |
| 168 return new Pair<String, String>(name, url); | 168 return new Pair<String, String>(name, url); |
| 169 } | 169 } |
| 170 } | 170 } |
| OLD | NEW |