| 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 /** | 5 /** |
| 6 * A source from which to install packages. | 6 * A source from which to install packages. |
| 7 * | 7 * |
| 8 * Each source has many packages that it looks up using [PackageId]s. The source | 8 * 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. | 9 * is responsible for installing these packages to the package cache. |
| 10 */ | 10 */ |
| 11 class Source { | 11 class Source { |
| 12 /** | 12 /** |
| 13 * The default [Source] from which to fetch packages if no other [Source] is |
| 14 * specified. |
| 15 */ |
| 16 static Source defaultSource; |
| 17 |
| 18 /** |
| 19 * Looks up a source based on its name. |
| 20 */ |
| 21 static Source fromName(String name) { |
| 22 // TODO(nweiz): add a more principled way of registering sources here once |
| 23 // we have more than one source. Especially important for plugins. |
| 24 if (name == 'sdk') return defaultSource; |
| 25 throw 'Unknown source "$name"'; |
| 26 } |
| 27 |
| 28 /** |
| 13 * The name of the source. Should be lower-case, suitable for use in a | 29 * The name of the source. Should be lower-case, suitable for use in a |
| 14 * filename, and unique accross all sources. | 30 * filename, and unique accross all sources. |
| 15 */ | 31 */ |
| 16 abstract String get name(); | 32 abstract String get name(); |
| 17 | 33 |
| 18 /** | 34 /** |
| 19 * Whether this source's packages should be cached in Pub's global cache | 35 * Whether this source's packages should be cached in Pub's global cache |
| 20 * directory. | 36 * directory. |
| 21 * | 37 * |
| 22 * A source should be cached if it requires network access to retrieve | 38 * A source should be cached if it requires network access to retrieve |
| (...skipping 23 matching lines...) Expand all Loading... |
| 46 * resolution logic. | 62 * resolution logic. |
| 47 * | 63 * |
| 48 * This method should be light-weight. It doesn't need to validate that the | 64 * This method should be light-weight. It doesn't need to validate that the |
| 49 * given package exists. | 65 * given 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.fullName; |
| 55 } | 71 } |
| OLD | NEW |