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
31
32
33
34
35
36
37
38
39
|
require 'rubygems'
require 'xmlsimple'
require 'builder'
x = XmlSimple.xml_in(STDIN.read)
entries = x["logentry"].collect do |entry|
{
:message => entry["msg"],
:author => entry["author"],
:date => entry["date"].to_s.sub(/\.\d+(?=Z)/, ''),
:revision => entry["revision"]
}
end
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 {
entries.each do |entry|
plist.dict {
plist.key "message"
plist.string entry[:message]
plist.key "date"
plist.date entry[:date]
plist.key "revision"
plist.integer entry[:revision]
plist.key "author"
plist.string entry[:author]
}
end
}
}
}
|