| 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'); |
| 6 |
| 7 #import('io.dart'); |
| 8 #import('pub.dart'); |
| 9 #import('utils.dart'); |
| 10 |
| 11 #source('git_source.dart'); |
| 12 #source('sdk_source.dart'); |
| 13 #source('source_registry.dart'); |
| 14 |
| 5 /** | 15 /** |
| 6 * A source from which to install packages. | 16 * A source from which to install packages. |
| 7 * | 17 * |
| 8 * Each source has many packages that it looks up using [PackageId]s. The source | 18 * Each source has many packages that it looks up using [PackageId]s. The source |
| 9 * is responsible for installing these packages to the package cache. | 19 * is responsible for installing these packages to the package cache. |
| 10 */ | 20 */ |
| 11 class Source { | 21 class Source { |
| 12 /** | 22 /** |
| 13 * The name of the source. Should be lower-case, suitable for use in a | 23 * The name of the source. Should be lower-case, suitable for use in a |
| 14 * filename, and unique accross all sources. | 24 * filename, and unique accross all sources. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 34 * If [shouldCache] is true, [path] will be a path to this source's | 44 * If [shouldCache] is true, [path] will be a path to this source's |
| 35 * subdirectory of the [PackageCache]'s cache directory. If [shouldCache] is | 45 * subdirectory of the [PackageCache]'s cache directory. If [shouldCache] is |
| 36 * false, [path] will be a path to the application's "packages" directory. | 46 * false, [path] will be a path to the application's "packages" directory. |
| 37 * | 47 * |
| 38 * [path] is guaranteed not to exist, and its parent directory is guaranteed | 48 * [path] is guaranteed not to exist, and its parent directory is guaranteed |
| 39 * to exist. | 49 * to exist. |
| 40 */ | 50 */ |
| 41 abstract Future<bool> install(PackageId id, String path); | 51 abstract Future<bool> install(PackageId id, String path); |
| 42 | 52 |
| 43 /** | 53 /** |
| 44 * Returns the name of the package identified by [id]. By default, this is | 54 * When a [Pubspec] is parsed, it reads in the description for each |
| 45 * just `id.fullName`, but some sources (e.g. Git) may have more complicated | 55 * dependency. It is up to the dependency's [Source] to determine how that |
| 46 * resolution logic. | 56 * should be interpreted. This will be called during parsing to validate that |
| 47 * | 57 * the given [description] is well-formed according to this source. It should |
| 48 * This method should be light-weight. It doesn't need to validate that the | 58 * return if the description is valid, or throw a [FormatException] if not. |
| 49 * given package exists. | 59 */ |
| 60 void validateDescription(description) {} |
| 61 |
| 62 /** |
| 63 * Returns a human-friendly name for the package identified by [id]. This |
| 64 * method should be light-weight. It doesn't need to validate that the given |
| 65 * package exists. |
| 50 * | 66 * |
| 51 * The package name should be lower-case and suitable for use in a filename. | 67 * The package name should be lower-case and suitable for use in a filename. |
| 52 * It may contain forward slashes. | 68 * It may contain forward slashes. |
| 53 */ | 69 */ |
| 54 String packageName(PackageId id) => id.fullName; | 70 String packageName(PackageId id) => id.description; |
| 55 } | 71 } |
| OLD | NEW |