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

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

Issue 10749014: Refactor Source to take the system cache as a parameter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge 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
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 return extractTarGz(httpGet(fullUrl), destDir); 44 return extractTarGz(httpGet(fullUrl), destDir);
45 }); 45 });
46 } 46 }
47 47
48 /** 48 /**
49 * The system cache directory for the repo source contains subdirectories for 49 * The system cache directory for the repo source contains subdirectories for
50 * each separate repository URL that's used on the system. Each of these 50 * each separate repository URL that's used on the system. Each of these
51 * subdirectories then contains a subdirectory for each package installed from 51 * subdirectories then contains a subdirectory for each package installed from
52 * that repository. 52 * that repository.
53 */ 53 */
54 String systemCacheDirectory(PackageId id, String parent) { 54 String systemCacheDirectory(PackageId id) {
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(systemCacheRoot, urlDir, "${parsed.first}-${id.version}");
61 } 61 }
62 62
63 String packageName(description) => _parseDescription(description).first; 63 String packageName(description) => _parseDescription(description).first;
64 64
65 bool descriptionsEqual(description1, description2) => 65 bool descriptionsEqual(description1, description2) =>
66 _parseDescription(description1) == _parseDescription(description2); 66 _parseDescription(description1) == _parseDescription(description2);
67 67
68 /** 68 /**
69 * Ensures that [description] is a valid repo description. 69 * Ensures that [description] is a valid repo description.
70 * 70 *
(...skipping 29 matching lines...) Expand all
100 100
101 var name = description["name"]; 101 var name = description["name"];
102 if (name is! String) { 102 if (name is! String) {
103 throw new FormatException("The 'name' key must have a string value."); 103 throw new FormatException("The 'name' key must have a string value.");
104 } 104 }
105 105
106 var url = description.containsKey("url") ? description["url"] : defaultUrl; 106 var url = description.containsKey("url") ? description["url"] : defaultUrl;
107 return new Pair<String, String>(name, url); 107 return new Pair<String, String>(name, url);
108 } 108 }
109 } 109 }
OLDNEW
« no previous file with comments | « utils/pub/pub.dart ('k') | utils/pub/source.dart » ('j') | utils/pub/system_cache.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698