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 'dart:async'; | 7 import 'dart:async'; |
| 8 |
| 9 import '../../pkg/path/lib/path.dart' as path; |
| 10 |
8 import 'io.dart'; | 11 import 'io.dart'; |
9 import 'pubspec.dart'; | 12 import 'pubspec.dart'; |
10 import 'source.dart'; | 13 import 'source.dart'; |
11 import 'source_registry.dart'; | 14 import 'source_registry.dart'; |
12 import 'version.dart'; | 15 import 'version.dart'; |
13 | 16 |
14 final _README_REGEXP = new RegExp(r"^README($|\.)", caseSensitive: false); | 17 final _README_REGEXP = new RegExp(r"^README($|\.)", caseSensitive: false); |
15 | 18 |
16 /// A named, versioned, unit of code and resource reuse. | 19 /// A named, versioned, unit of code and resource reuse. |
17 class Package { | 20 class Package { |
18 /// The path to the directory containing the package. | 21 /// The path to the directory containing the package. |
19 final String dir; | 22 final String dir; |
20 | 23 |
21 /// The name of the package. | 24 /// The name of the package. |
22 String get name { | 25 String get name { |
23 if (pubspec.name != null) return pubspec.name; | 26 if (pubspec.name != null) return pubspec.name; |
24 if (dir != null) return basename(dir); | 27 if (dir != null) return path.basename(dir); |
25 return null; | 28 return null; |
26 } | 29 } |
27 | 30 |
28 /// The package's version. | 31 /// The package's version. |
29 Version get version => pubspec.version; | 32 Version get version => pubspec.version; |
30 | 33 |
31 /// The parsed pubspec associated with this package. | 34 /// The parsed pubspec associated with this package. |
32 final Pubspec pubspec; | 35 final Pubspec pubspec; |
33 | 36 |
34 /// The ids of the packages that this package depends on. This is what is | 37 /// The ids of the packages that this package depends on. This is what is |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 | 208 |
206 class PubspecNameMismatchException implements Exception { | 209 class PubspecNameMismatchException implements Exception { |
207 final String expectedName; | 210 final String expectedName; |
208 final String actualName; | 211 final String actualName; |
209 | 212 |
210 PubspecNameMismatchException(this.expectedName, this.actualName); | 213 PubspecNameMismatchException(this.expectedName, this.actualName); |
211 | 214 |
212 String toString() => 'The name you specified for your dependency, ' | 215 String toString() => 'The name you specified for your dependency, ' |
213 '"$expectedName", doesn\'t match the name "$actualName" in its pubspec.'; | 216 '"$expectedName", doesn\'t match the name "$actualName" in its pubspec.'; |
214 } | 217 } |
OLD | NEW |