require "rexml/document"
include REXML
Dir.chdir("./docs")
outf=File.new("../graphs/GRAPH.xml",'w')
data=Hash.new
Dir['*.xml'].each do |filename|
doc=Document.new File.new(filename)
as=XPath.first(doc, "//assignees/assignee/addressbook/orgname")
if as
assignee=as.text
else
assignee="NO_ASSIGNEE"
end
puts "#{filename}---#{assignee}"
if data[assignee]
data[assignee]=data[assignee]+1
else
data[assignee]=1
end
end
barfile=File.open("../graphs/bar.xml")
bars=barfile.readlines
filestr=''
#clean data
data.delete("NO_ASSIGNEE")
#==========
data.each { |assignee,count|
filestr=filestr+"<point name=\"#{assignee}\" y=\"#{count}\"/>" if count>4
}
bars[-6]=filestr
bars.each do |line|
outf.puts line
end
суббота, 14 сентября 2013 г.
XML creator on Ruby
Подписаться на:
Комментарии к сообщению (Atom)
Комментариев нет:
Отправить комментарий