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

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

Issue 12092080: Validate packages against their SDK constraints. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. Created 7 years, 10 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/io.dart ('k') | utils/pub/pubspec.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 package; 5 library package;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'io.dart'; 8 import 'io.dart';
9 import 'pubspec.dart'; 9 import 'pubspec.dart';
10 import 'source.dart'; 10 import 'source.dart';
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 } 51 }
52 52
53 /// The package's version. 53 /// The package's version.
54 Version get version => pubspec.version; 54 Version get version => pubspec.version;
55 55
56 /// The parsed pubspec associated with this package. 56 /// The parsed pubspec associated with this package.
57 final Pubspec pubspec; 57 final Pubspec pubspec;
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 Collection<PackageRef> get dependencies => pubspec.dependencies; 61 List<PackageRef> get dependencies => pubspec.dependencies;
62 62
63 /// Returns the path to the README file at the root of the entrypoint, or null 63 /// Returns the path to the README file at the root of the entrypoint, or null
64 /// if no README file is found. If multiple READMEs are found, this uses the 64 /// if no README file is found. If multiple READMEs are found, this uses the
65 /// same conventions as pub.dartlang.org for choosing the primary one: the 65 /// same conventions as pub.dartlang.org for choosing the primary one: the
66 /// README with the fewest extensions that is lexically ordered first is 66 /// README with the fewest extensions that is lexically ordered first is
67 /// chosen. 67 /// chosen.
68 Future<String> get readmePath { 68 Future<String> get readmePath {
69 return listDir(dir).then((entries) { 69 return listDir(dir).then((entries) {
70 var readmes = entries.where((entry) => entry.contains(_README_REGEXP)); 70 var readmes = entries.where((entry) => entry.contains(_README_REGEXP));
71 if (readmes.isEmpty) return; 71 if (readmes.isEmpty) return;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 /// by the URL "git://github.com/dart/uilib.git". 117 /// by the URL "git://github.com/dart/uilib.git".
118 final description; 118 final description;
119 119
120 PackageId(this.name, this.source, this.version, this.description); 120 PackageId(this.name, this.source, this.version, this.description);
121 121
122 /// Whether this ID identifies the root package. 122 /// Whether this ID identifies the root package.
123 bool get isRoot => source == null; 123 bool get isRoot => source == null;
124 124
125 int get hashCode => name.hashCode ^ source.hashCode ^ version.hashCode; 125 int get hashCode => name.hashCode ^ source.hashCode ^ version.hashCode;
126 126
127 /// Gets the directory where this package is or would be found in the
128 /// [SystemCache].
129 Future<String> get systemCacheDirectory => source.systemCacheDirectory(this);
130
127 bool operator ==(other) { 131 bool operator ==(other) {
128 if (other is! PackageId) return false; 132 if (other is! PackageId) return false;
129 // TODO(rnystrom): We're assuming here the name/version/source tuple is 133 // TODO(rnystrom): We're assuming here the name/version/source tuple is
130 // enough to uniquely identify the package and that we don't need to delve 134 // enough to uniquely identify the package and that we don't need to delve
131 // into the description. 135 // into the description.
132 return other.name == name && 136 return other.name == name &&
133 other.source == source && 137 other.source == source &&
134 other.version == version; 138 other.version == version;
135 } 139 }
136 140
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 223
220 class PubspecNameMismatchException implements Exception { 224 class PubspecNameMismatchException implements Exception {
221 final String expectedName; 225 final String expectedName;
222 final String actualName; 226 final String actualName;
223 227
224 PubspecNameMismatchException(this.expectedName, this.actualName); 228 PubspecNameMismatchException(this.expectedName, this.actualName);
225 229
226 String toString() => 'The name you specified for your dependency, ' 230 String toString() => 'The name you specified for your dependency, '
227 '"$expectedName", doesn\'t match the name "$actualName" in its pubspec.'; 231 '"$expectedName", doesn\'t match the name "$actualName" in its pubspec.';
228 } 232 }
OLDNEW
« no previous file with comments | « utils/pub/io.dart ('k') | utils/pub/pubspec.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698