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

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

Issue 11638010: Convert /** comments to /// in pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Respond to review. Created 8 years 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/oauth2.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 lock_file; 5 library lock_file;
6 6
7 import 'dart:json'; 7 import 'dart:json';
8 import 'package.dart'; 8 import 'package.dart';
9 import 'source_registry.dart'; 9 import 'source_registry.dart';
10 import 'utils.dart'; 10 import 'utils.dart';
11 import 'version.dart'; 11 import 'version.dart';
12 import 'yaml/yaml.dart'; 12 import 'yaml/yaml.dart';
13 13
14 /** 14 /// A parsed and validated `pubspec.lock` file.
15 * A parsed and validated `pubspec.lock` file.
16 */
17 class LockFile { 15 class LockFile {
18 /** 16 /// The packages this lockfile pins.
19 * The packages this lockfile pins.
20 */
21 Map<String, PackageId> packages; 17 Map<String, PackageId> packages;
22 18
23 LockFile._(this.packages); 19 LockFile._(this.packages);
24 20
25 LockFile.empty() 21 LockFile.empty()
26 : packages = <String, PackageId>{}; 22 : packages = <String, PackageId>{};
27 23
28 /** 24 /// Parses the lockfile whose text is [contents].
29 * Parses the lockfile whose text is [contents].
30 */
31 factory LockFile.parse(String contents, SourceRegistry sources) { 25 factory LockFile.parse(String contents, SourceRegistry sources) {
32 var packages = <String, PackageId>{}; 26 var packages = <String, PackageId>{};
33 27
34 if (contents.trim() == '') return new LockFile.empty(); 28 if (contents.trim() == '') return new LockFile.empty();
35 29
36 var parsed = loadYaml(contents); 30 var parsed = loadYaml(contents);
37 31
38 if (parsed.containsKey('packages')) { 32 if (parsed.containsKey('packages')) {
39 var packageEntries = parsed['packages']; 33 var packageEntries = parsed['packages'];
40 34
(...skipping 30 matching lines...) Expand all
71 "Package name $name doesn't match ${id.name}."); 65 "Package name $name doesn't match ${id.name}.");
72 } 66 }
73 67
74 packages[name] = id; 68 packages[name] = id;
75 }); 69 });
76 } 70 }
77 71
78 return new LockFile._(packages); 72 return new LockFile._(packages);
79 } 73 }
80 74
81 /** 75 /// Returns the serialized YAML text of the lock file.
82 * Returns the serialized YAML text of the lock file.
83 */
84 String serialize() { 76 String serialize() {
85 var packagesObj = <String, Map>{}; 77 var packagesObj = <String, Map>{};
86 packages.forEach((name, id) { 78 packages.forEach((name, id) {
87 packagesObj[name] = { 79 packagesObj[name] = {
88 'version': id.version.toString(), 80 'version': id.version.toString(),
89 'source': id.source.name, 81 'source': id.source.name,
90 'description': id.description 82 'description': id.description
91 }; 83 };
92 }); 84 });
93 85
94 // TODO(nweiz): Serialize using the YAML library once it supports 86 // TODO(nweiz): Serialize using the YAML library once it supports
95 // serialization. For now, we use JSON, since it's a subset of YAML anyway. 87 // serialization. For now, we use JSON, since it's a subset of YAML anyway.
96 return JSON.stringify({'packages': packagesObj}); 88 return JSON.stringify({'packages': packagesObj});
97 } 89 }
98 } 90 }
OLDNEW
« no previous file with comments | « utils/pub/io.dart ('k') | utils/pub/oauth2.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698