| 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('package'); | 5 #library('package'); |
| 6 | 6 |
| 7 #import('io.dart'); | 7 #import('io.dart'); |
| 8 #import('pubspec.dart'); | 8 #import('pubspec.dart'); |
| 9 #import('source.dart'); | 9 #import('source.dart'); |
| 10 #import('source_registry.dart'); | 10 #import('source_registry.dart'); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 final String dir; | 41 final String dir; |
| 42 | 42 |
| 43 /** | 43 /** |
| 44 * The name of the package. | 44 * The name of the package. |
| 45 */ | 45 */ |
| 46 final String name; | 46 final String name; |
| 47 | 47 |
| 48 /** | 48 /** |
| 49 * The package's version. | 49 * The package's version. |
| 50 */ | 50 */ |
| 51 Version get version() => pubspec.version; | 51 Version get version => pubspec.version; |
| 52 | 52 |
| 53 /** | 53 /** |
| 54 * The parsed pubspec associated with this package. | 54 * The parsed pubspec associated with this package. |
| 55 */ | 55 */ |
| 56 final Pubspec pubspec; | 56 final Pubspec pubspec; |
| 57 | 57 |
| 58 /** | 58 /** |
| 59 * The ids of the packages that this package depends on. This is what is | 59 * The ids of the packages that this package depends on. This is what is |
| 60 * specified in the pubspec when this package depends on another. | 60 * specified in the pubspec when this package depends on another. |
| 61 */ | 61 */ |
| 62 Collection<PackageRef> get dependencies() => pubspec.dependencies; | 62 Collection<PackageRef> get dependencies => pubspec.dependencies; |
| 63 | 63 |
| 64 /** | 64 /** |
| 65 * Constructs a package with the given name and pubspec. The package will | 65 * Constructs a package with the given name and pubspec. The package will |
| 66 * no directory associated with it. | 66 * no directory associated with it. |
| 67 */ | 67 */ |
| 68 Package.inMemory(this.name, this.pubspec) | 68 Package.inMemory(this.name, this.pubspec) |
| 69 : dir = null; | 69 : dir = null; |
| 70 | 70 |
| 71 /** | 71 /** |
| 72 * Constructs a package. This should not be called directly. Instead, acquire | 72 * Constructs a package. This should not be called directly. Instead, acquire |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 * by the URL "git://github.com/dart/uilib.git". | 109 * by the URL "git://github.com/dart/uilib.git". |
| 110 */ | 110 */ |
| 111 final description; | 111 final description; |
| 112 | 112 |
| 113 PackageId(this.source, this.version, this.description); | 113 PackageId(this.source, this.version, this.description); |
| 114 | 114 |
| 115 /** | 115 /** |
| 116 * The name of the package being identified. This will be the human-friendly | 116 * The name of the package being identified. This will be the human-friendly |
| 117 * name like "uilib". | 117 * name like "uilib". |
| 118 */ | 118 */ |
| 119 String get name() => source.packageName(description); | 119 String get name => source.packageName(description); |
| 120 | 120 |
| 121 int hashCode() => name.hashCode() ^ | 121 int hashCode() => name.hashCode() ^ |
| 122 source.name.hashCode() ^ | 122 source.name.hashCode() ^ |
| 123 version.hashCode(); | 123 version.hashCode(); |
| 124 | 124 |
| 125 bool operator ==(other) { | 125 bool operator ==(other) { |
| 126 if (other is! PackageId) return false; | 126 if (other is! PackageId) return false; |
| 127 // TODO(rnystrom): We're assuming here the name/version/source tuple is | 127 // TODO(rnystrom): We're assuming here the name/version/source tuple is |
| 128 // enough to uniquely identify the package and that we don't need to delve | 128 // enough to uniquely identify the package and that we don't need to delve |
| 129 // into the description. | 129 // into the description. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 147 } | 147 } |
| 148 | 148 |
| 149 /** | 149 /** |
| 150 * Returns the pubspec for this package. | 150 * Returns the pubspec for this package. |
| 151 */ | 151 */ |
| 152 Future<Pubspec> describe() => source.describe(this); | 152 Future<Pubspec> describe() => source.describe(this); |
| 153 | 153 |
| 154 /** | 154 /** |
| 155 * Returns a future that completes to the resovled [PackageId] for this id. | 155 * Returns a future that completes to the resovled [PackageId] for this id. |
| 156 */ | 156 */ |
| 157 Future<PackageId> get resolved() => source.resolveId(this); | 157 Future<PackageId> get resolved => source.resolveId(this); |
| 158 } | 158 } |
| 159 | 159 |
| 160 /** | 160 /** |
| 161 * A reference to a package. Unlike a [PackageId], a PackageRef may not | 161 * A reference to a package. Unlike a [PackageId], a PackageRef may not |
| 162 * unambiguously refer to a single package. It may describe a range of allowed | 162 * unambiguously refer to a single package. It may describe a range of allowed |
| 163 * packages. | 163 * packages. |
| 164 */ | 164 */ |
| 165 class PackageRef { | 165 class PackageRef { |
| 166 /** | 166 /** |
| 167 * The [Source] used to look up the package. | 167 * The [Source] used to look up the package. |
| 168 */ | 168 */ |
| 169 final Source source; | 169 final Source source; |
| 170 | 170 |
| 171 /** | 171 /** |
| 172 * The allowed package versions. | 172 * The allowed package versions. |
| 173 */ | 173 */ |
| 174 final VersionConstraint constraint; | 174 final VersionConstraint constraint; |
| 175 | 175 |
| 176 /** | 176 /** |
| 177 * The metadata used to identify the package being referenced. The | 177 * The metadata used to identify the package being referenced. The |
| 178 * interpretation of this will vary based on the [source]. | 178 * interpretation of this will vary based on the [source]. |
| 179 */ | 179 */ |
| 180 final description; | 180 final description; |
| 181 | 181 |
| 182 /** | 182 /** |
| 183 * The name of the package being referenced. | 183 * The name of the package being referenced. |
| 184 */ | 184 */ |
| 185 String get name() => source.packageName(description); | 185 String get name => source.packageName(description); |
| 186 | 186 |
| 187 PackageRef(this.source, this.constraint, this.description); | 187 PackageRef(this.source, this.constraint, this.description); |
| 188 | 188 |
| 189 String toString() => "$name $constraint from $source ($description)"; | 189 String toString() => "$name $constraint from $source ($description)"; |
| 190 | 190 |
| 191 /** | 191 /** |
| 192 * Returns a [PackageId] generated from this [PackageRef] with the given | 192 * Returns a [PackageId] generated from this [PackageRef] with the given |
| 193 * concrete version. | 193 * concrete version. |
| 194 */ | 194 */ |
| 195 PackageId atVersion(Version version) => | 195 PackageId atVersion(Version version) => |
| 196 new PackageId(source, version, description); | 196 new PackageId(source, version, description); |
| 197 } | 197 } |
| OLD | NEW |