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

Side by Side Diff: sdk/lib/_internal/pub/lib/src/lock_file.dart

Issue 15777002: Use indentation for maps in lockfile. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. Created 7 years, 7 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
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' as json;
8 import 'dart:collection'; 7 import 'dart:collection';
9 8
10 import 'package:yaml/yaml.dart'; 9 import 'package:yaml/yaml.dart';
11 10
12 import 'io.dart'; 11 import 'io.dart';
12 import 'log.dart' as log;
13 import 'package.dart'; 13 import 'package.dart';
14 import 'source_registry.dart'; 14 import 'source_registry.dart';
15 import 'utils.dart'; 15 import 'utils.dart';
16 import 'version.dart'; 16 import 'version.dart';
17 17
18 /// A parsed and validated `pubspec.lock` file. 18 /// A parsed and validated `pubspec.lock` file.
19 class LockFile { 19 class LockFile {
20 /// The packages this lockfile pins. 20 /// The packages this lockfile pins.
21 Map<String, PackageId> packages; 21 Map<String, PackageId> packages;
22 22
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 packages[name] = id; 82 packages[name] = id;
83 }); 83 });
84 } 84 }
85 85
86 return new LockFile._(packages); 86 return new LockFile._(packages);
87 } 87 }
88 88
89 /// Returns the serialized YAML text of the lock file. 89 /// Returns the serialized YAML text of the lock file.
90 String serialize() { 90 String serialize() {
91 var packagesObj = new LinkedHashMap<String, Map>(); 91 // Convert the dependencies to a simple object.
92 92 var data = {};
93 // Sort the packages by name. 93 packages.forEach((name, package) {
94 var sortedKeys = packages.keys.toList(); 94 data[name] = {
95 sortedKeys.sort();
96 sortedKeys.forEach((name) {
97 packagesObj[name] = {
98 'version': packages[name].version.toString(), 95 'version': packages[name].version.toString(),
99 'source': packages[name].source, 96 'source': packages[name].source,
100 'description': packages[name].description 97 'description': packages[name].description
101 }; 98 };
102 }); 99 });
103 100
104 // TODO(nweiz): Serialize using the YAML library once it supports 101 return """
105 // serialization. For now, we use JSON, since it's a subset of YAML anyway. 102 # Generated by pub
106 return 103 # See http://pub.dartlang.org/doc/glossary.html#lockfile
107 '# Generated by pub\n' 104 ${yamlToString({'packages': data})}
108 '# See http://pub.dartlang.org/doc/glossary.html#lockfile\n' 105 """;
109 '\n'
110 '${json.stringify({'packages': packagesObj})}\n';
111 } 106 }
112 } 107 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/pub/lib/src/solver/version_solver.dart » ('j') | sdk/lib/_internal/pub/lib/src/utils.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698