1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env ruby

require 'rubygems'
require 'xmlsimple'
require 'builder'

logxml = XmlSimple.xml_in(STDIN.read)

plist = Builder::XmlMarkup.new(:target => STDOUT, :indent => 2)
plist.instruct!
plist.declare! :DOCTYPE, :plist, :PUBLIC, "-//Apple Computer//DTD PLIST 1.0//EN"
plist.plist("version" => "http://www.apple.com/DTDs/PropertyList-1.0.dtd") {
  plist.dict {
    plist.key "logEntries"
    plist.array {
      logxml["logentry"].each do |entry|
        plist.dict {
          plist.key "message"
          plist.string entry["msg"]
          plist.key "date"
          plist.date entry["date"].to_s.sub(/\.\d+(?=Z)/, '')
          plist.key "revision"
          plist.integer entry["revision"]
          plist.key "author"
          plist.string entry["author"]
        }
      end
    }
  }
}