| 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('source'); | 5 #library('source'); |
| 6 | 6 |
| 7 #import('io.dart'); | 7 #import('io.dart'); |
| 8 #import('package.dart'); | 8 #import('package.dart'); |
| 9 #import('pubspec.dart'); | 9 #import('pubspec.dart'); |
| 10 #import('system_cache.dart'); | 10 #import('system_cache.dart'); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 this._systemCache = systemCache; | 64 this._systemCache = systemCache; |
| 65 } | 65 } |
| 66 | 66 |
| 67 /** | 67 /** |
| 68 * Get the list of all versions that exist for the package described by | 68 * Get the list of all versions that exist for the package described by |
| 69 * [description]. | 69 * [description]. |
| 70 * | 70 * |
| 71 * Note that this does *not* require the packages to be installed, which is | 71 * Note that this does *not* require the packages to be installed, which is |
| 72 * the point. This is used during version resolution to determine which | 72 * the point. This is used during version resolution to determine which |
| 73 * package versions are available to be installed (or already installed). | 73 * package versions are available to be installed (or already installed). |
| 74 * |
| 75 * By default, this assumes that each description has a single version and |
| 76 * uses [describe] to get that version. |
| 74 */ | 77 */ |
| 75 Future<List<Version>> getVersions(description) { | 78 Future<List<Version>> getVersions(description) { |
| 76 // TODO(rnystrom): Do something better here. | 79 return describe(new PackageId(this, Version.none, description)) |
| 77 throw "Source $name doesn't support versioning."; | 80 .transform((pubspec) => [pubspec.version]); |
| 78 } | 81 } |
| 79 | 82 |
| 80 /** | 83 /** |
| 81 * Loads the (possibly remote) pubspec for the package version identified by | 84 * Loads the (possibly remote) pubspec for the package version identified by |
| 82 * [id]. This will be called for packages that have not yet been installed | 85 * [id]. This may be called for packages that have not yet been installed |
| 83 * during the version resolution process. | 86 * during the version resolution process. |
| 87 * |
| 88 * For cached sources, by default this uses [installToSystemCache] to get the |
| 89 * pubspec. There is no default implementation for non-cached sources; they |
| 90 * must implement it manually. |
| 84 */ | 91 */ |
| 85 Future<Pubspec> describe(PackageId id) { | 92 Future<Pubspec> describe(PackageId id) { |
| 86 // TODO(rnystrom): Figure out how non-default sources should handle this. | 93 if (!shouldCache) throw "Source $name must implement describe(id)."; |
| 87 throw "Source $name doesn't support versioning."; | 94 return installToSystemCache(id).transform((package) => package.pubspec); |
| 88 } | 95 } |
| 89 | 96 |
| 90 /** | 97 /** |
| 91 * Installs the package identified by [id] to [path]. Returns a [Future] that | 98 * Installs the package identified by [id] to [path]. Returns a [Future] that |
| 92 * completes when the installation was finished. The [Future] should resolve | 99 * completes when the installation was finished. The [Future] should resolve |
| 93 * to true if the package was found in the source and false if it wasn't. For | 100 * to true if the package was found in the source and false if it wasn't. For |
| 94 * all other error conditions, it should complete with an exception. | 101 * all other error conditions, it should complete with an exception. |
| 95 * | 102 * |
| 96 * [path] is guaranteed not to exist, and its parent directory is guaranteed | 103 * [path] is guaranteed not to exist, and its parent directory is guaranteed |
| 97 * to exist. | 104 * to exist. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 * Returns whether or not [description1] describes the same package as | 165 * Returns whether or not [description1] describes the same package as |
| 159 * [description2] for this source. This method should be light-weight. It | 166 * [description2] for this source. This method should be light-weight. It |
| 160 * doesn't need to validate that either package exists. | 167 * doesn't need to validate that either package exists. |
| 161 * | 168 * |
| 162 * By default, this assumes both descriptions are strings and compares them | 169 * By default, this assumes both descriptions are strings and compares them |
| 163 * for equality. | 170 * for equality. |
| 164 */ | 171 */ |
| 165 bool descriptionsEqual(description1, description2) => | 172 bool descriptionsEqual(description1, description2) => |
| 166 description1 == description2; | 173 description1 == description2; |
| 167 } | 174 } |
| OLD | NEW |