| 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'); |
| 11 #import('version.dart'); | 11 #import('version.dart'); |
| 12 | 12 |
| 13 /** | 13 /** |
| 14 * A named, versioned, unit of code and resource reuse. | 14 * A named, versioned, unit of code and resource reuse. |
| 15 */ | 15 */ |
| 16 class Package { | 16 class Package { |
| 17 /** | 17 /** |
| 18 * Loads the package whose root directory is [packageDir]. | 18 * Loads the package whose root directory is [packageDir]. |
| 19 */ | 19 */ |
| 20 static Future<Package> load(String packageDir, SourceRegistry sources) { | 20 static Future<Package> load(String packageDir, SourceRegistry sources) { |
| 21 var pubspecPath = join(packageDir, 'pubspec'); | 21 var pubspecPath = join(packageDir, 'pubspec.yaml'); |
| 22 | 22 |
| 23 return fileExists(pubspecPath).chain((exists) { | 23 return fileExists(pubspecPath).chain((exists) { |
| 24 if (exists) { | 24 if (exists) { |
| 25 return readTextFile(pubspecPath).transform((contents) { | 25 return readTextFile(pubspecPath).transform((contents) { |
| 26 return new Pubspec.parse(contents, sources); | 26 return new Pubspec.parse(contents, sources); |
| 27 }); | 27 }); |
| 28 } else { | 28 } else { |
| 29 // If there is no pubspec, we implicitly treat that as a package with | 29 // If there is no pubspec, we implicitly treat that as a package with |
| 30 // no dependencies. | 30 // no dependencies. |
| 31 return new Future.immediate(new Pubspec.empty()); | 31 return new Future.immediate(new Pubspec.empty()); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 /** | 164 /** |
| 165 * The metadata used to identify the package being referenced. The | 165 * The metadata used to identify the package being referenced. The |
| 166 * interpretation of this will vary based on the [source]. | 166 * interpretation of this will vary based on the [source]. |
| 167 */ | 167 */ |
| 168 final description; | 168 final description; |
| 169 | 169 |
| 170 PackageRef(this.name, this.source, this.version, this.description); | 170 PackageRef(this.name, this.source, this.version, this.description); |
| 171 | 171 |
| 172 String toString() => "$name $version from $source ($description)"; | 172 String toString() => "$name $version from $source ($description)"; |
| 173 } | 173 } |
| OLD | NEW |