2007-04-15 05:22:30 +00:00
|
|
|
#!/usr/bin/ruby
|
|
|
|
#
|
|
|
|
# rebuildGrooves
|
|
|
|
# Vocalese
|
|
|
|
#
|
|
|
|
# Created by Matthias Neeracher on 2/5/07.
|
|
|
|
# Copyright (c) 2007 __MyCompanyName__. All rights reserved.
|
|
|
|
#
|
|
|
|
|
|
|
|
require 'find'
|
|
|
|
|
|
|
|
grooves = {}
|
|
|
|
Find.find(ARGV[0]) do |f|
|
|
|
|
if File.directory?(f)
|
|
|
|
Find.prune if File.exist?("f/MMAIGNORE")
|
|
|
|
elsif f =~ %r|.*/(\S+?).mma$|
|
|
|
|
style = $1
|
|
|
|
g = {}
|
2007-05-02 05:28:22 +00:00
|
|
|
o = []
|
2007-04-15 05:22:30 +00:00
|
|
|
doc = ""
|
|
|
|
groove= ""
|
|
|
|
File.open(f) do |file|
|
|
|
|
inDoc = false
|
|
|
|
inCont= false
|
|
|
|
file.each do |line|
|
|
|
|
if line =~ /^\s*Begin\s+Doc\s*$/
|
|
|
|
inDoc = true
|
|
|
|
elsif inDoc
|
|
|
|
if line =~ /^\s*End\s*$/
|
|
|
|
inDoc = false
|
|
|
|
else
|
|
|
|
doc = doc+" "+line.strip
|
|
|
|
end
|
|
|
|
elsif line =~ /^\s*DefGroove\s+(\S+)\s+(.+?)\s*$/
|
|
|
|
groove = $1
|
|
|
|
gdoc = $2
|
2007-05-02 05:28:22 +00:00
|
|
|
o.push(groove)
|
2007-04-15 05:22:30 +00:00
|
|
|
if gdoc =~ /(.*?)\s+\\\s*$/
|
|
|
|
gdoc = $1
|
|
|
|
inCont = true
|
|
|
|
end
|
|
|
|
g[groove] = gdoc
|
|
|
|
elsif inCont
|
|
|
|
if line =~ /^\s*(.*?)\s*(\\)?\s*$/
|
|
|
|
g[groove] = g[groove] + " " + $1
|
|
|
|
inCont = $2 != nil
|
|
|
|
else
|
|
|
|
inCont = false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
unless g.empty?
|
2007-05-02 05:28:22 +00:00
|
|
|
g[".DESC"] = doc.lstrip
|
|
|
|
g[".ORDER"] = o
|
2007-04-15 05:22:30 +00:00
|
|
|
grooves[style] = g
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
OUT = File.new(ARGV[1], "w")
|
|
|
|
|
|
|
|
OUT.print <<'END_HEADER'
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
|
|
<plist version="1.0">
|
|
|
|
<dict>
|
|
|
|
END_HEADER
|
|
|
|
|
|
|
|
def xmlesc(s)
|
2011-07-26 21:52:33 +00:00
|
|
|
s.gsub('&', '&').gsub('<', '<').gsub('>', '>')
|
2007-04-15 05:22:30 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
grooves.each do |style,grooves|
|
|
|
|
OUT.puts "\t<key>#{xmlesc(style)}</key>"
|
|
|
|
OUT.puts "\t<dict>"
|
|
|
|
grooves.each do |name,desc|
|
|
|
|
OUT.puts "\t\t<key>#{xmlesc(name)}</key>"
|
2007-05-02 05:28:22 +00:00
|
|
|
if name == ".ORDER"
|
|
|
|
OUT.puts "\t\t<array>"
|
|
|
|
desc.each do |name|
|
|
|
|
OUT.puts "\t\t\t<string>#{xmlesc(name)}</string>"
|
|
|
|
end
|
|
|
|
OUT.puts "\t\t</array>"
|
|
|
|
else
|
|
|
|
OUT.puts "\t\t<string>#{xmlesc(desc)}</string>"
|
|
|
|
end
|
2007-04-15 05:22:30 +00:00
|
|
|
end
|
|
|
|
OUT.puts "\t</dict>"
|
|
|
|
end
|
|
|
|
|
|
|
|
OUT.puts "</dict>"
|
|
|
|
OUT.puts "</plist>"
|
|
|
|
|