summaryrefslogtreecommitdiff
path: root/bin/normalize-stdio
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2014-09-05 01:31:14 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2014-09-05 01:31:14 -0400
commit4b70501e432eb5fd9ed04a4afbadafabd982e9fc (patch)
treeb09fe80d9ec0ec3eb82f46dbfce960dc66aaf3f4 /bin/normalize-stdio
parent1ab58422fb47e22e178716efa3fbce5beabbc174 (diff)
restructure to have most data in YAML
Diffstat (limited to 'bin/normalize-stdio')
-rwxr-xr-xbin/normalize-stdio31
1 files changed, 31 insertions, 0 deletions
diff --git a/bin/normalize-stdio b/bin/normalize-stdio
new file mode 100755
index 0000000..23a240e
--- /dev/null
+++ b/bin/normalize-stdio
@@ -0,0 +1,31 @@
+#!/usr/bin/env ruby
+require 'yaml'
+
+core_order = [ "username",
+ "fullname",
+ "email",
+ "groups",
+ "pgp_keyid",
+ "pgp_revoked_keyids",
+ "ssh_keys",
+ "extra" ]
+
+extra_order = [ "alias",
+ "other_contact",
+ "roles",
+ "website",
+ "occupation",
+ "yob",
+ "location",
+ "languages",
+ "interests",
+ "favorite_distros" ]
+
+_core_order = Hash[[*core_order.map.with_index]]
+_extra_order = Hash[[*extra_order.map.with_index]]
+
+print YAML::load(STDIN)
+ .sort_by{|u| u["username"]}
+ .map{|u| Hash[u.sort_by{|k,v| _core_order[k]}]}
+ .each{|u|u["extra"] = Hash[u["extra"].sort_by{|k,v| _extra_order[k]}] if u["extra"]}
+ .to_yaml