Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Side by Side Diff: utils/pub/pubspec.dart

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « utils/pub/pub.dart ('k') | utils/pub/sdk_source.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 return new Pubspec(name, version, dependencies, parsedPubspec); 126 return new Pubspec(name, version, dependencies, parsedPubspec);
127 } 127 }
128 } 128 }
129 129
130 List<PackageRef> _parseDependencies(SourceRegistry sources, yaml) { 130 List<PackageRef> _parseDependencies(SourceRegistry sources, yaml) {
131 var dependencies = <PackageRef>[]; 131 var dependencies = <PackageRef>[];
132 132
133 // Allow an empty dependencies key. 133 // Allow an empty dependencies key.
134 if (yaml == null) return dependencies; 134 if (yaml == null) return dependencies;
135 135
136 if (yaml is! Map || yaml.keys.some((e) => e is! String)) { 136 if (yaml is! Map || yaml.keys.any((e) => e is! String)) {
137 throw new FormatException( 137 throw new FormatException(
138 'The pubspec dependencies should be a map of package names, but ' 138 'The pubspec dependencies should be a map of package names, but '
139 'was ${yaml}.'); 139 'was ${yaml}.');
140 } 140 }
141 141
142 yaml.forEach((name, spec) { 142 yaml.forEach((name, spec) {
143 var description, source; 143 var description, source;
144 var versionConstraint = new VersionRange(); 144 var versionConstraint = new VersionRange();
145 if (spec == null) { 145 if (spec == null) {
146 description = name; 146 description = name;
147 source = sources.defaultSource; 147 source = sources.defaultSource;
148 } else if (spec is String) { 148 } else if (spec is String) {
149 description = name; 149 description = name;
150 source = sources.defaultSource; 150 source = sources.defaultSource;
151 versionConstraint = new VersionConstraint.parse(spec); 151 versionConstraint = new VersionConstraint.parse(spec);
152 } else if (spec is Map) { 152 } else if (spec is Map) {
153 if (spec.containsKey('version')) { 153 if (spec.containsKey('version')) {
154 versionConstraint = new VersionConstraint.parse(spec.remove('version')); 154 versionConstraint = new VersionConstraint.parse(spec.remove('version'));
155 } 155 }
156 156
157 var sourceNames = spec.keys; 157 var sourceNames = spec.keys.toList();
158 if (sourceNames.length > 1) { 158 if (sourceNames.length > 1) {
159 throw new FormatException( 159 throw new FormatException(
160 'Dependency $name may only have one source: $sourceNames.'); 160 'Dependency $name may only have one source: $sourceNames.');
161 } 161 }
162 162
163 var sourceName = only(sourceNames); 163 var sourceName = only(sourceNames);
164 if (sourceName is! String) { 164 if (sourceName is! String) {
165 throw new FormatException( 165 throw new FormatException(
166 'Source name $sourceName should be a string.'); 166 'Source name $sourceName should be a string.');
167 } 167 }
168 168
169 source = sources[sourceName]; 169 source = sources[sourceName];
170 description = spec[sourceName]; 170 description = spec[sourceName];
171 } else { 171 } else {
172 throw new FormatException( 172 throw new FormatException(
173 'Dependency specification $spec should be a string or a mapping.'); 173 'Dependency specification $spec should be a string or a mapping.');
174 } 174 }
175 175
176 source.validateDescription(description, fromLockFile: false); 176 source.validateDescription(description, fromLockFile: false);
177 177
178 dependencies.add(new PackageRef( 178 dependencies.add(new PackageRef(
179 name, source, versionConstraint, description)); 179 name, source, versionConstraint, description));
180 }); 180 });
181 181
182 return dependencies; 182 return dependencies;
183 } 183 }
OLDNEW
« no previous file with comments | « utils/pub/pub.dart ('k') | utils/pub/sdk_source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698