The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
How You Fake a Gem Server

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Red Handed

Posts: 1158
Nickname: redhanded
Registered: Dec, 2004

Red Handed is a Ruby-focused group blog.
How You Fake a Gem Server Posted: Mar 28, 2006 10:31 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Red Handed.
Original Post: How You Fake a Gem Server
Feed Title: RedHanded
Feed URL: http://redhanded.hobix.com/index.xml
Feed Description: sneaking Ruby through the system
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Red Handed
Latest Posts From RedHanded

Advertisement

It’s odd that RubyGems doesn’t serve its own docs. See gem_server for yourself. In fact, where are the pro-grade gem docs?

 require 'rubygems/format'
 GEM_SERVER_DIR = "/var/www/htdocs" 
 specs =
 Dir[GEM_SERVER_DIR + "/gems/*.gem"].inject({}) do |hsh, path|
 name = File.basename(path).sub(/\.gem$/,'')
 hsh.merge name => Gem::Format.from_file_by_path(path).spec
 end
 index = Gem::SourceIndex.new specs
 yaml_write = proc { |f| f.write index.to_yaml }
 File.open(GEM_SERVER_DIR + "/yaml", "w", &yaml_write)
 Zlib::GzipWriter.open(GEM_SERVER_DIR + "/yaml.Z", &yaml_write)

That’s a fake gem server. But you have to make a /var/www/htdocs directory. Then, fill up /var/www/htdocs/gems with the all the gems you want to serve. Put this script in cron and it’ll generate the indices.

The Rails team uses a well-concealed gem_update.sh, but there’s opportunity in the above to to use the gemspecs to create an HTML index as well, which could be snazzy.

Read: How You Fake a Gem Server

Topic: Request: 3rd party Ruby libs Previous Topic   Next Topic Topic: Moore's Law is crap

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use