| 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 pub.source; | 5 library pub.source; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:path/path.dart' as path; | 9 import 'package:path/path.dart' as path; |
| 10 | 10 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 /// [FormatException] if not valid. | 221 /// [FormatException] if not valid. |
| 222 /// | 222 /// |
| 223 /// [fromLockFile] is true when the description comes from a [LockFile], to | 223 /// [fromLockFile] is true when the description comes from a [LockFile], to |
| 224 /// allow the source to use lockfile-specific descriptions via [resolveId]. | 224 /// allow the source to use lockfile-specific descriptions via [resolveId]. |
| 225 dynamic parseDescription(String containingPath, description, | 225 dynamic parseDescription(String containingPath, description, |
| 226 {bool fromLockFile: false}) { | 226 {bool fromLockFile: false}) { |
| 227 return description; | 227 return description; |
| 228 } | 228 } |
| 229 | 229 |
| 230 /// When a [LockFile] is serialized, it uses this method to get the | 230 /// When a [LockFile] is serialized, it uses this method to get the |
| 231 /// [description] in the right format. [containingPath] references the | 231 /// [description] in the right format. |
| 232 /// containing directory of the root package. | 232 /// |
| 233 /// [containingPath] is the containing directory of the root package. |
| 233 dynamic serializeDescription(String containingPath, description) { | 234 dynamic serializeDescription(String containingPath, description) { |
| 234 return description; | 235 return description; |
| 235 } | 236 } |
| 236 | 237 |
| 238 /// When a package [description] is shown to the user, this is called to |
| 239 /// convert it into a human-friendly form. |
| 240 /// |
| 241 /// By default, it just converts the description to a string, but sources |
| 242 /// may customize this. [containingPath] is the containing directory of the |
| 243 /// root package. |
| 244 String formatDescription(String containingPath, description) { |
| 245 return description.toString(); |
| 246 } |
| 247 |
| 237 /// Returns whether or not [description1] describes the same package as | 248 /// Returns whether or not [description1] describes the same package as |
| 238 /// [description2] for this source. This method should be light-weight. It | 249 /// [description2] for this source. This method should be light-weight. It |
| 239 /// doesn't need to validate that either package exists. | 250 /// doesn't need to validate that either package exists. |
| 240 /// | 251 /// |
| 241 /// By default, just uses regular equality. | 252 /// By default, just uses regular equality. |
| 242 bool descriptionsEqual(description1, description2) => | 253 bool descriptionsEqual(description1, description2) => |
| 243 description1 == description2; | 254 description1 == description2; |
| 244 | 255 |
| 245 /// For some sources, [PackageId]s can point to different chunks of code at | 256 /// For some sources, [PackageId]s can point to different chunks of code at |
| 246 /// different times. This takes such an [id] and returns a future that | 257 /// different times. This takes such an [id] and returns a future that |
| (...skipping 18 matching lines...) Expand all Loading... |
| 265 /// Returns the [Package]s that have been downloaded to the system cache. | 276 /// Returns the [Package]s that have been downloaded to the system cache. |
| 266 List<Package> getCachedPackages() { | 277 List<Package> getCachedPackages() { |
| 267 if (shouldCache) { | 278 if (shouldCache) { |
| 268 throw new UnimplementedError("Source $name must implement this."); | 279 throw new UnimplementedError("Source $name must implement this."); |
| 269 } | 280 } |
| 270 } | 281 } |
| 271 | 282 |
| 272 /// Returns the source's name. | 283 /// Returns the source's name. |
| 273 String toString() => name; | 284 String toString() => name; |
| 274 } | 285 } |
| OLD | NEW |