[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Rubygems front end?

Ezra Zygmuntowicz

9/28/2006 5:36:00 PM

Does one exist? I wanted to have a look at how one would go about
it. Or to be more specific, I need to make a web interface that I can
use to search the available gems, and list their descriptions and
versions. I can use the normal gem command line to actually install
stuff. But I want to do quick local auto complete searches of
available gems.

Basically all I need is the info that comes from a gem list --
remote. But I want to pull this info every few hours and insert it
into my database so I can use it in my web interface. What would be
the most polite way of doing this as far as rubygems are concerned?
Should I just parse the gem list --remote with regexes? Doesn't seem
like the way to go really. And http://docs.rub... is down
right now so I can't read up on it.

Is there an easier way to do this built into rubygems already? I
suppose my next step will be to just read the source and figure it
out but if anyone has suggestions then please let me know,.


Cheers-
-Ezra


3 Answers

David Roberts

9/29/2006 8:36:00 AM

0

Ezra Zygmuntowicz wrote:
> Does one exist?

There is the beginnings of a project at 'rubyslippers' on Rubyforge.
[last activity 18 months ago.]

And I thought I had seen something with a 'native' GUI [rubyslippers
uses rwd] but I can't find it...

Also, there was this thread on rubygems-developers -

http://rubyforge.org/pipermail/rubygems-developers/2004-March/0...

hth

deejay

--
Posted via http://www.ruby-....

Matthew Harris

9/29/2006 1:11:00 PM

0

The Gem.source_index contains a source index object that contains lots
of information on available packages.

On 9/29/06, Ezra Zygmuntowicz <ezmobius@gmail.com> wrote:
> Does one exist? I wanted to have a look at how one would go about
> it. Or to be more specific, I need to make a web interface that I can
> use to search the available gems, and list their descriptions and
> versions. I can use the normal gem command line to actually install
> stuff. But I want to do quick local auto complete searches of
> available gems.
>
> Basically all I need is the info that comes from a gem list --
> remote. But I want to pull this info every few hours and insert it
> into my database so I can use it in my web interface. What would be
> the most polite way of doing this as far as rubygems are concerned?
> Should I just parse the gem list --remote with regexes? Doesn't seem
> like the way to go really. And http://docs.rub... is down
> right now so I can't read up on it.
>
> Is there an easier way to do this built into rubygems already? I
> suppose my next step will be to just read the source and figure it
> out but if anyone has suggestions then please let me know,.
>
>
> Cheers-
> -Ezra
>
>
>


--
Matt

Ezra Zygmuntowicz

9/29/2006 3:31:00 PM

0

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