| 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('dartlang_source'); | 5 #library('dartlang_source'); |
| 6 | 6 |
| 7 #import('dart:io'); | 7 #import('dart:io'); |
| 8 #import('dart:json'); | 8 #import('dart:json'); |
| 9 #import('dart:uri'); | 9 #import('dart:uri'); |
| 10 #import('io.dart'); | 10 #import('io.dart'); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 _parseDescription(description1) == _parseDescription(description2); | 97 _parseDescription(description1) == _parseDescription(description2); |
| 98 | 98 |
| 99 /** | 99 /** |
| 100 * Ensures that [description] is a valid repo description. | 100 * Ensures that [description] is a valid repo description. |
| 101 * | 101 * |
| 102 * There are two valid formats. A plain string refers to a package with the | 102 * There are two valid formats. A plain string refers to a package with the |
| 103 * given name from the default repository, while a map with keys "name" and | 103 * given name from the default repository, while a map with keys "name" and |
| 104 * "url" refers to a package with the given name from the repo at the given | 104 * "url" refers to a package with the given name from the repo at the given |
| 105 * URL. | 105 * URL. |
| 106 */ | 106 */ |
| 107 void validateDescription(description) { | 107 void validateDescription(description, [bool fromLockFile=false]) { |
| 108 _parseDescription(description); | 108 _parseDescription(description); |
| 109 } | 109 } |
| 110 | 110 |
| 111 /** | 111 /** |
| 112 * Parses the description blob for a package. | 112 * Parses the description blob for a package. |
| 113 * | 113 * |
| 114 * If the package parses correctly, this returns a (name, url) pair. If not, | 114 * If the package parses correctly, this returns a (name, url) pair. If not, |
| 115 * this throws a descriptive FormatException. | 115 * this throws a descriptive FormatException. |
| 116 */ | 116 */ |
| 117 Pair<String, String> _parseDescription(description) { | 117 Pair<String, String> _parseDescription(description) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 131 | 131 |
| 132 var name = description["name"]; | 132 var name = description["name"]; |
| 133 if (name is! String) { | 133 if (name is! String) { |
| 134 throw new FormatException("The 'name' key must have a string value."); | 134 throw new FormatException("The 'name' key must have a string value."); |
| 135 } | 135 } |
| 136 | 136 |
| 137 var url = description.containsKey("url") ? description["url"] : defaultUrl; | 137 var url = description.containsKey("url") ? description["url"] : defaultUrl; |
| 138 return new Pair<String, String>(name, url); | 138 return new Pair<String, String>(name, url); |
| 139 } | 139 } |
| 140 } | 140 } |
| OLD | NEW |