Skip to content

Instantly share code, notes, and snippets.

@sushain97
Last active September 11, 2015 18:56
Show Gist options
  • Save sushain97/ab21d4363aeeddfe10b4 to your computer and use it in GitHub Desktop.
Save sushain97/ab21d4363aeeddfe10b4 to your computer and use it in GitHub Desktop.
irb(main):040:0> xml = `svn log --xml https://svn.code.sf.net/p/apertium/svn/#{ARGV[0]}/apertium-#{ARGV[1]}`; nil
=> nil
irb(main):041:0> require 'nokogiri'
=> true
irb(main):042:0> doc = Nokogiri::XML(xml); nil
=> nil
irb(main):043:0> authors = Hash.new(0)
=> {}
irb(main):044:0> doc.xpath("//author").each { |author| authors[author.text] += 1 }
=> 0
irb(main):045:0> authors
=> {"trondtr"=>2, "selimcan"=>671, "unhammer"=>14, "spectre360"=>36, "abdik"=>1, "jonorthwash"=>89, "aglimzan"=>4}
irb(main):046:0> require 'json'
=> true
irb(main):058:0> puts (authors.to_a.map { |author| { :user => author[0], :value => author[1]} }).to_json
[{"user":"selimcan","value":672},{"user":"trondtr","value":2},{"user":"unhammer","value":14},{"user":"spectre360","value":36},{"user":"abdik","value":1},{"user":"jonorthwash","value":89},{"user":"aglimzan","value":4}]
=> nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment