diff options
-rwxr-xr-x | projects/devdashboard/devdashboard.rb | 27 | ||||
-rw-r--r-- | projects/devdashboard/developer.rb | 4 | ||||
-rw-r--r-- | projects/devdashboard/doccacher.rb | 5 | ||||
-rw-r--r-- | projects/devdashboard/docparser.rb | 60 | ||||
-rw-r--r-- | projects/devdashboard/metadataparser.rb | 109 | ||||
-rw-r--r-- | projects/devdashboard/userinfo.rb | 2 |
6 files changed, 166 insertions, 41 deletions
diff --git a/projects/devdashboard/devdashboard.rb b/projects/devdashboard/devdashboard.rb index f868688..aeaae68 100755 --- a/projects/devdashboard/devdashboard.rb +++ b/projects/devdashboard/devdashboard.rb @@ -1,25 +1,28 @@ #!/usr/bin/ruby -w -require 'developer.rb' -require 'herds.rb' -require 'userinfo.rb' -require 'docparser.rb' -require 'planetiniparser.rb' +require 'developer' +require 'herds' +require 'userinfo' +require 'docparser' +require 'planetiniparser' +require 'metadataparser' include Herds include UserInfo include PlanetIniParser +include MetadataHelper dev = Developer.new dev.handle = ARGV[0] -#dev.handle = 'nichoj' UserInfo.updateDev(dev) Herds.updateDev(dev) +MetadataHelper.updateDev(dev) PlanetIniParser.updateDev(dev) dev.documentation = findDocumentation(dev.email) + puts "Name: #{dev.name}" puts "Username: #{dev.handle}" puts "Email: #{dev.email}" @@ -38,11 +41,15 @@ unless dev.blogRss.nil? dev.blogItems.each { |item| puts "\t#{item.title}" } puts "Hackergotchi: #{dev.hackergotchi}" unless dev.hackergotchi.nil? end -puts "Commits RSS: #{dev.ciaRss}" -puts "Commits: " -dev.commitItems.each { |item| puts "\t#{item.title}" } -puts "Bugs RSS: #{dev.myBugsRss}" +#puts "Commits RSS: #{dev.ciaRss}" +#puts "Commits: " +#dev.commitItems.each { |item| puts "\t#{item.title}" } +#puts "Bugs RSS: #{dev.myBugsRss}" puts "Forums Profile: #{dev.forumsProfile}" +puts "Packages:" +unless dev.packages.nil? + dev.packages.each { |package| puts "\t#{package}" } +end unless dev.documentation.nil? puts "Documentation:" diff --git a/projects/devdashboard/developer.rb b/projects/devdashboard/developer.rb index ea7bd40..4856137 100644 --- a/projects/devdashboard/developer.rb +++ b/projects/devdashboard/developer.rb @@ -4,8 +4,8 @@ require 'rss/2.0' require 'open-uri' class Developer - attr_reader :name, :handle, :blogRss, :pgpkey, :email, :joined, :birthday, :roles, :location, :herds, :hackergotchi, :forumsHandle, :documentation - attr_writer :name, :handle, :blogRss, :pgpkey, :email, :joined, :birthday, :roles, :location, :herds, :hackergotchi, :forumsHandle, :documentation + attr_reader :name, :handle, :blogRss, :pgpkey, :email, :joined, :birthday, :roles, :location, :herds, :hackergotchi, :forumsHandle, :documentation, :packages + attr_writer :name, :handle, :blogRss, :pgpkey, :email, :joined, :birthday, :roles, :location, :herds, :hackergotchi, :forumsHandle, :documentation, :packages def initialize() end diff --git a/projects/devdashboard/doccacher.rb b/projects/devdashboard/doccacher.rb new file mode 100644 index 0000000..b555f9b --- /dev/null +++ b/projects/devdashboard/doccacher.rb @@ -0,0 +1,5 @@ +#!/usr/bin/ruby -w + +require 'docparser.rb' + +findDocumentation("nichoj@gentoo.org") diff --git a/projects/devdashboard/docparser.rb b/projects/devdashboard/docparser.rb index 22ed7cc..22ce566 100644 --- a/projects/devdashboard/docparser.rb +++ b/projects/devdashboard/docparser.rb @@ -1,6 +1,10 @@ #!/usr/bin/ruby -w require 'rexml/document' require 'find' +#require 'sqlite' +#require 'active_record' + +#ActiveRecord::Base.establish_connection(:adapter => "sqlite", :database => "./dbfile") include REXML @@ -20,38 +24,38 @@ end def findDocumentation(target) documents = [] - Find.find("/home/jnichols/checkouts/gentoo/xml/htdocs") do |filename| - if isXml? filename - file = File.new(filename) - begin - doc = Document.new(file) - - root = doc.root - title_text = nil - case doc.doctype.system - when "/dtd/guide.dtd": - title = root.elements['title'] - title_text = title.text unless title.nil? + targetdir="/local/home/checkouts/gentoo-website/xml/htdocs/proj/en/java/" + Dir.glob("#{targetdir}/**/*.xml").each do |filename| +# Find.find("/home/jnichols/checkouts/gentoo/xml/htdocs/proj/en/java") do |filename| + file = File.new(filename) + begin + doc = Document.new(file) + + root = doc.root + title_text = nil + case doc.doctype.system + when "/dtd/guide.dtd": + title = root.elements['title'] + title_text = title.text unless title.nil? - when "/dtd/project.dtd": - longname = root.elements['longname'] - title_text = longname.text unless longname.nil? - else next - end - - - root.elements.each('author') do |author| - role = author.attributes['title'] - email = author.elements['mail'].attributes['link'] - if email == target - documents.push Documentation.new(role, title_text, filename) - end + when "/dtd/project.dtd": + longname = root.elements['longname'] + title_text = longname.text unless longname.nil? + else next + end + + + root.elements.each('author') do |author| + role = author.attributes['title'] + email = author.elements['mail'].attributes['link'] + if email == target + documentation = Documentation.new(role,title_text,filename) + documents.push documentation end - rescue Exception - # catching all exceptions probably is bad :) end + rescue Exception + # catching all exceptions probably is bad :) end - Find.prune if filename =~ /CVS/ end return documents diff --git a/projects/devdashboard/metadataparser.rb b/projects/devdashboard/metadataparser.rb new file mode 100644 index 0000000..2f7c5fa --- /dev/null +++ b/projects/devdashboard/metadataparser.rb @@ -0,0 +1,109 @@ +#!/usr/bin/ruby -w +require 'rexml/document' +require 'find' + +include REXML + + +module MetadataHelper + def MetadataHelper.isMetadata?(filename) + filename =~ /metadata\.xml$/ + end + + class Metadata + attr_reader :herds, :maintainers, :longdescription, :package + attr_writer :herds, :maintainers, :longdescription, :package + def initialize() + self.herds = Array.new + self.maintainers = Array.new + end + end + + class Maintainer + attr_reader :email, :name + attr_writer :email, :name + end + + + def MetadataHelper.parse_metadata (filename) + metadata = Metadata.new + + file = File.new(filename) + package = File.basename(File.dirname(filename)) + category = File.basename(File.dirname(File.dirname(filename))) + fullpackage = "#{category}/#{package}" + metadata.package = fullpackage + + doc = Document.new(file) + root = doc.root + + puts "Indexing #{filename}..." + root.elements.each('herd') do |herd| + metadata.herds.push herd.text + end + + root.elements.each('maintainer') do |maintainer_node| + maintainer = Maintainer.new + email = maintainer_node.elements['email'] + maintainer.email = email.text unless email.nil? + name = maintainer_node.elements['name'] + maintainer.name = name.text unless name.nil? + + metadata.maintainers.push maintainer + end + return metadata + end + + def MetadataHelper.parse_directory(directory) + indexed_metadata = [] + targetdir="/local/home/checkouts/gentoo-portage-tree/dev-java" + Dir.glob("#{targetdir}/**/*/metadata.xml").each do |filename| +# Find.find("/local/home/checkouts/gentoo-portage-tree/dev-java") do |filename| + if isMetadata? filename + metadata = parse_metadata(filename) + unless metadata.maintainers.empty? and metadata.herds.empty? + indexed_metadata.push(metadata) + end + end + end + + return indexed_metadata + end + + def MetadataHelper.updateDev(dev) + indexed_metadata = parse_directory("/local/home/checkouts/gentoo-portage-tree/dev-java") + + if dev.packages.nil? + dev.packages = [] + end + indexed_metadata.each do |metadata| + unless metadata.maintainers.empty? + metadata.maintainers.each do |maintainer| + if dev.email == maintainer.email + dev.packages.push metadata.package + end + end + + end + end + + end +end + + + +#indexed_metadata.each do |metadata| +# puts "* #{metadata.package}" +# unless metadata.herds.empty? +# puts "\tHerds:" +# puts "\t\t#{metadata.herds}" unless metadata.herds.empty? +# end +# unless metadata.maintainers.empty? +# puts "\tMaintainers:" +# metadata.maintainers.each do |maintainer| +# puts "\t\tname: #{maintainer.name}" +# puts "\t\temail: #{maintainer.email}" +# end +# puts +# end +#end diff --git a/projects/devdashboard/userinfo.rb b/projects/devdashboard/userinfo.rb index baa0f52..f508f4e 100644 --- a/projects/devdashboard/userinfo.rb +++ b/projects/devdashboard/userinfo.rb @@ -4,7 +4,7 @@ include REXML module UserInfo def UserInfo.parse(handle) - file = File.new('/home/jnichols/checkouts/gentoo/xml/htdocs/proj/en/devrel/roll-call/userinfo.xml') + file = File.new('/local/home/checkouts/gentoo-website/xml/htdocs/proj/en/devrel/roll-call/userinfo.xml') doc = Document.new(file) root = doc.root user = root.elements["user[@username='" + handle + "']"] |