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

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

Issue 12253054: Get rid of join() and encapsulate File and Directory in io.dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase. Created 7 years, 10 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/git_source.dart ('k') | utils/pub/io.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 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';
11 11
12 // TODO(nweiz): Make this import better. 12 // TODO(nweiz): Make this import better.
13 import '../../pkg/http/lib/http.dart' as http; 13 import '../../pkg/http/lib/http.dart' as http;
14 import '../../pkg/path/lib/path.dart' as path;
15
14 import 'http.dart'; 16 import 'http.dart';
15 import 'io.dart'; 17 import 'io.dart';
16 import 'log.dart' as log; 18 import 'log.dart' as log;
17 import 'package.dart'; 19 import 'package.dart';
18 import 'pubspec.dart'; 20 import 'pubspec.dart';
19 import 'source.dart'; 21 import 'source.dart';
20 import 'source_registry.dart'; 22 import 'source_registry.dart';
21 import 'utils.dart'; 23 import 'utils.dart';
22 import 'version.dart'; 24 import 'version.dart';
23 25
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 /// subdirectories then contains a subdirectory for each package installed 94 /// subdirectories then contains a subdirectory for each package installed
93 /// from that site. 95 /// from that site.
94 Future<String> systemCacheDirectory(PackageId id) { 96 Future<String> systemCacheDirectory(PackageId id) {
95 var parsed = _parseDescription(id.description); 97 var parsed = _parseDescription(id.description);
96 var url = parsed.last.replaceAll(new RegExp(r"^https?://"), ""); 98 var url = parsed.last.replaceAll(new RegExp(r"^https?://"), "");
97 var urlDir = replace(url, new RegExp(r'[<>:"\\/|?*%]'), (match) { 99 var urlDir = replace(url, new RegExp(r'[<>:"\\/|?*%]'), (match) {
98 return '%${match[0].charCodeAt(0)}'; 100 return '%${match[0].charCodeAt(0)}';
99 }); 101 });
100 102
101 return new Future.immediate( 103 return new Future.immediate(
102 join(systemCacheRoot, urlDir, "${parsed.first}-${id.version}")); 104 path.join(systemCacheRoot, urlDir, "${parsed.first}-${id.version}"));
103 } 105 }
104 106
105 String packageName(description) => _parseDescription(description).first; 107 String packageName(description) => _parseDescription(description).first;
106 108
107 bool descriptionsEqual(description1, description2) => 109 bool descriptionsEqual(description1, description2) =>
108 _parseDescription(description1) == _parseDescription(description2); 110 _parseDescription(description1) == _parseDescription(description2);
109 111
110 /// Ensures that [description] is a valid hosted package description. 112 /// Ensures that [description] is a valid hosted package description.
111 /// 113 ///
112 /// There are two valid formats. A plain string refers to a package with the 114 /// There are two valid formats. A plain string refers to a package with the
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 161
160 var name = description["name"]; 162 var name = description["name"];
161 if (name is! String) { 163 if (name is! String) {
162 throw new FormatException("The 'name' key must have a string value."); 164 throw new FormatException("The 'name' key must have a string value.");
163 } 165 }
164 166
165 var url = description.containsKey("url") ? description["url"] : defaultUrl; 167 var url = description.containsKey("url") ? description["url"] : defaultUrl;
166 return new Pair<String, String>(name, url); 168 return new Pair<String, String>(name, url);
167 } 169 }
168 } 170 }
OLDNEW
« no previous file with comments | « utils/pub/git_source.dart ('k') | utils/pub/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698