Skip to content

Instantly share code, notes, and snippets.

@kei-s
Created April 18, 2012 16:44
Show Gist options
  • Save kei-s/2414927 to your computer and use it in GitHub Desktop.
Save kei-s/2414927 to your computer and use it in GitHub Desktop.
Channel data from TwitterIRCGateway to tig
require 'json'
require 'nokogiri'
doc = Nokogiri::XML(File.read('./Groups.xml'))
result = doc.search('Group').map{|g|
{g: g.search('Name').text, ms: g.search('Members string').map(&:text)}
}
json = {}
result.map{|g|g[:ms]}.flatten.uniq.map{|u|
json[u] = result.select{|g|g[:ms].include? u}.map{|g|g[:g]}
}
puts json.to_json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment