| 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 pubspec; | 5 library pubspec; |
| 6 | 6 |
| 7 import 'package.dart'; | 7 import 'package.dart'; |
| 8 import 'source.dart'; | 8 import 'source.dart'; |
| 9 import 'source_registry.dart'; | 9 import 'source_registry.dart'; |
| 10 import 'utils.dart'; | 10 import 'utils.dart'; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 Pubspec(this.name, this.version, this.dependencies); | 33 Pubspec(this.name, this.version, this.dependencies); |
| 34 | 34 |
| 35 Pubspec.empty() | 35 Pubspec.empty() |
| 36 : name = null, | 36 : name = null, |
| 37 version = Version.none, | 37 version = Version.none, |
| 38 dependencies = <PackageRef>[]; | 38 dependencies = <PackageRef>[]; |
| 39 | 39 |
| 40 /** Whether or not the pubspec has no contents. */ | 40 /** Whether or not the pubspec has no contents. */ |
| 41 bool get isEmpty => | 41 bool get isEmpty => |
| 42 name == null && version == Version.none && dependencies.isEmpty(); | 42 name == null && version == Version.none && dependencies.isEmpty; |
| 43 | 43 |
| 44 /** | 44 /** |
| 45 * Parses the pubspec whose text is [contents]. If the pubspec doesn't define | 45 * Parses the pubspec whose text is [contents]. If the pubspec doesn't define |
| 46 * version for itself, it defaults to [Version.none]. | 46 * version for itself, it defaults to [Version.none]. |
| 47 */ | 47 */ |
| 48 factory Pubspec.parse(String contents, SourceRegistry sources) { | 48 factory Pubspec.parse(String contents, SourceRegistry sources) { |
| 49 var name = null; | 49 var name = null; |
| 50 var version = Version.none; | 50 var version = Version.none; |
| 51 var dependencies = <PackageRef>[]; | 51 var dependencies = <PackageRef>[]; |
| 52 | 52 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 156 |
| 157 if (parsedPubspec.containsKey('author')) { | 157 if (parsedPubspec.containsKey('author')) { |
| 158 throw new FormatException('A pubspec should not have both an "author" ' | 158 throw new FormatException('A pubspec should not have both an "author" ' |
| 159 'and an "authors" field.'); | 159 'and an "authors" field.'); |
| 160 } | 160 } |
| 161 } | 161 } |
| 162 | 162 |
| 163 return new Pubspec(name, version, dependencies); | 163 return new Pubspec(name, version, dependencies); |
| 164 } | 164 } |
| 165 } | 165 } |
| OLD | NEW |