From: Ezra Zygmuntowicz Date: 2006-09-30T00:30:58+09:00 Subject: Re: Rubygems front end? Thanks for the responses. I ended up just regexing the gem list -- remote output as it was simple to do. I'll share here in case someone else ends up wanting something like this. Here is a rake task that will pull the gem list and parse it into a hash with he name of the gem as the key and versions and descriptions as subhashes of the gem name key. THen it populates a bunch of GemIndex ActiveRecord Objects. namespace :parsegems do def parse_gems(gem_list) hsh={} last = '' gem_list.each do |line| case line when /(\w+)\s+\((.*?)\)/ (hsh[$1] ||= {})[:versions]=$2 last = $1 when /\A(\s+\w.*?)\Z/ (hsh[last][:desc] ||= '') << ($1+' ') end end hsh end desc 'Gets the gems list --remote and parse it into the app_gems database table for quick autocomplete.' task :import => :environment do hsh = parse_gems(`gem list --remote`) hsh.keys.each do |key| g = GemIndex.find_or_create_by_name(key) g.update_attributes :versions => hsh[key][:versions], :description => hsh[key][:desc] puts "Imported Gem Data for: #{key}" end end end Cheers- -Ezra