| 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 abstract class Source { | 19 abstract 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 /// Whether or not this source is the default source. |
| 27 bool get isDefault => systemCache.sources.defaultSource == this; |
| 28 |
| 26 /** | 29 /** |
| 27 * Whether this source's packages should be cached in Pub's global cache | 30 * Whether this source's packages should be cached in Pub's global cache |
| 28 * directory. | 31 * directory. |
| 29 * | 32 * |
| 30 * A source should be cached if it requires network access to retrieve | 33 * 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 | 34 * packages. It doesn't need to be cached if all packages are available |
| 32 * locally. | 35 * locally. |
| 33 */ | 36 */ |
| 34 abstract bool get shouldCache; | 37 abstract bool get shouldCache; |
| 35 | 38 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 * resolved id. | 185 * resolved id. |
| 183 * | 186 * |
| 184 * The returned [PackageId] may have a description field that's invalid | 187 * The returned [PackageId] may have a description field that's invalid |
| 185 * according to [validateDescription], although it must still be serializable | 188 * according to [validateDescription], although it must still be serializable |
| 186 * to JSON and YAML. It must also be equal to [id] according to | 189 * to JSON and YAML. It must also be equal to [id] according to |
| 187 * [descriptionsEqual]. | 190 * [descriptionsEqual]. |
| 188 * | 191 * |
| 189 * By default, this just returns [id]. | 192 * By default, this just returns [id]. |
| 190 */ | 193 */ |
| 191 Future<PackageId> resolveId(PackageId id) => new Future.immediate(id); | 194 Future<PackageId> resolveId(PackageId id) => new Future.immediate(id); |
| 195 |
| 196 /// Returns the source's name. |
| 197 String toString() => name; |
| 192 } | 198 } |
| OLD | NEW |