Skip to content

Instantly share code, notes, and snippets.

@tsmango
Created August 25, 2009 16:19
Show Gist options
  • Save tsmango/174788 to your computer and use it in GitHub Desktop.
Save tsmango/174788 to your computer and use it in GitHub Desktop.
require 'open-uri'
namespace :parse do
task :teams => :environment do
api_key = ''
teams = Array.new
entry_names = Hash.new
entry_urls = Hash.new
(1..6).to_a.each do |page|
teams_response = JSON.parse(open("http://r09.railsrumble.com/teams.json?page=#{page}&api_key=#{api_key}").read)
teams_response.each do |team|
teams << team['team']['slug']
team_response = JSON.parse(open("http://r09.railsrumble.com/teams/#{team['team']['slug']}.json?api_key=#{api_key}").read)
entry_names[team['team']['slug']] = team_response['team']['entry']['name']
entry_urls[team['team']['slug']] = team_response['team']['entry']['direct_url']
end
end
puts 'TEAMS = [' + teams.sort.collect{|team| "{:team => \"#{team}\", :team_url => \"http://r09.railsrumble.com/teams/#{team}\", :project => \"#{entry_names[team]}\", :project_url => \"#{entry_urls[team]}\"}"}.join(', ') + ']'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment