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

Unified Diff: utils/pub/lock_file.dart

Issue 10968035: User friendlier YAML formatting for pubspec.lock (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: minor comment fix Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/lock_file.dart
diff --git a/utils/pub/lock_file.dart b/utils/pub/lock_file.dart
index 8e7042330731cdf8cdfb6b3953a4af83112c39f7..a87903de701cfaf13d8fa6f83b795d064647fdf4 100644
--- a/utils/pub/lock_file.dart
+++ b/utils/pub/lock_file.dart
@@ -93,6 +93,34 @@ class LockFile {
// TODO(nweiz): Serialize using the YAML library once it supports
// serialization. For now, we use JSON, since it's a subset of YAML anyway.
- return JSON.stringify({'packages': packagesObj});
+ //
+ // (prujohn@gmail.com) remove the _stringifyPretty() wrapper once the
+ // YAML impl ready.
+ return _stringifyPretty(packagesObj);
+ // return JSON.stringify({'packages' : packagesObj});
+ }
+
+ /**
+ * Provides a stringify on [packagesObj] to make the lock file more
+ * human-readable.
+ */
+ String _stringifyPretty(Map<String, Map> packagesObj){
+ final sb = new StringBuffer();
+
+ sb.add('packages:\n');
+ packagesObj.forEach((name, map){
+ sb.add(' ${name}:\n');
+ map.forEach((key, value){
+ if (key == "description" && value is Map){
+ sb.add(' description:\n');
+ value.forEach((dkey, dvalue){
+ sb.add(' ${dkey}: $dvalue\n');
+ });
+ }else{
+ sb.add(' ${key}: $value\n');
+ }
+ });
+ });
+ return sb.toString();
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698