| 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'); |
| 11 #import('version.dart'); | 11 #import('version.dart'); |
| 12 | 12 |
| 13 /** | 13 /** |
| 14 * A source from which to install packages. | 14 * A source from which to install packages. |
| 15 * | 15 * |
| 16 * Each source has many packages that it looks up using [PackageId]s. The source | 16 * Each source has many packages that it looks up using [PackageId]s. The source |
| 17 * is responsible for installing these packages to the package cache. | 17 * is responsible for installing these packages to the package cache. |
| 18 */ | 18 */ |
| 19 class Source { | 19 class Source { |
| 20 /** | 20 /** |
| 21 * The name of the source. Should be lower-case, suitable for use in a | 21 * The name of the source. Should be lower-case, suitable for use in a |
| 22 * filename, and unique accross all sources. | 22 * filename, and unique accross all sources. |
| 23 */ | 23 */ |
| 24 abstract String get name(); | 24 abstract String get name; |
| 25 | 25 |
| 26 /** | 26 /** |
| 27 * Whether this source's packages should be cached in Pub's global cache | 27 * Whether this source's packages should be cached in Pub's global cache |
| 28 * directory. | 28 * directory. |
| 29 * | 29 * |
| 30 * A source should be cached if it requires network access to retrieve | 30 * A source should be cached if it requires network access to retrieve |
| 31 * packages. It doesn't need to be cached if all packages are available | 31 * packages. It doesn't need to be cached if all packages are available |
| 32 * locally. | 32 * locally. |
| 33 */ | 33 */ |
| 34 abstract bool get shouldCache(); | 34 abstract bool get shouldCache; |
| 35 | 35 |
| 36 /** | 36 /** |
| 37 * The system cache with which this source is registered. | 37 * The system cache with which this source is registered. |
| 38 */ | 38 */ |
| 39 SystemCache get systemCache() { | 39 SystemCache get systemCache { |
| 40 assert(_systemCache != null); | 40 assert(_systemCache != null); |
| 41 return _systemCache; | 41 return _systemCache; |
| 42 } | 42 } |
| 43 | 43 |
| 44 /** | 44 /** |
| 45 * The system cache variable. Set by [_bind]. | 45 * The system cache variable. Set by [_bind]. |
| 46 */ | 46 */ |
| 47 SystemCache _systemCache; | 47 SystemCache _systemCache; |
| 48 | 48 |
| 49 /** | 49 /** |
| 50 * The root directory of this source's cache within the system cache. | 50 * The root directory of this source's cache within the system cache. |
| 51 * | 51 * |
| 52 * This shouldn't be overridden by subclasses. | 52 * This shouldn't be overridden by subclasses. |
| 53 */ | 53 */ |
| 54 String get systemCacheRoot() => join(systemCache.rootDir, name); | 54 String get systemCacheRoot => join(systemCache.rootDir, name); |
| 55 | 55 |
| 56 /** | 56 /** |
| 57 * Records the system cache to which this source belongs. | 57 * Records the system cache to which this source belongs. |
| 58 * | 58 * |
| 59 * This should only be called once for each source, by [SystemCache.register]. | 59 * This should only be called once for each source, by [SystemCache.register]. |
| 60 * It should not be overridden by base classes. | 60 * It should not be overridden by base classes. |
| 61 */ | 61 */ |
| 62 void bind(SystemCache systemCache) { | 62 void bind(SystemCache systemCache) { |
| 63 assert(_systemCache == null); | 63 assert(_systemCache == null); |
| 64 this._systemCache = systemCache; | 64 this._systemCache = systemCache; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 * | 189 * |
| 190 * The returned [PackageId] may have a description field that's invalid | 190 * The returned [PackageId] may have a description field that's invalid |
| 191 * according to [validateDescription], although it must still be serializable | 191 * according to [validateDescription], although it must still be serializable |
| 192 * to JSON and YAML. It must also be equal to [id] according to | 192 * to JSON and YAML. It must also be equal to [id] according to |
| 193 * [descriptionsEqual]. | 193 * [descriptionsEqual]. |
| 194 * | 194 * |
| 195 * By default, this just returns [id]. | 195 * By default, this just returns [id]. |
| 196 */ | 196 */ |
| 197 Future<PackageId> resolveId(PackageId id) => new Future.immediate(id); | 197 Future<PackageId> resolveId(PackageId id) => new Future.immediate(id); |
| 198 } | 198 } |
| OLD | NEW |