From: Chad Fowler Date: 2005-03-25T22:30:19+09:00 Subject: Re: Syntax for gem list file when hosting own rubygems repository On Thu, 24 Mar 2005 23:39:30 +0900, Richard Kilmer wrote: > Well...documentation...no, but its a good idea to document. Here is what > you need to do in a nutshell (what kind of nut...): > > You need webserver/virtual host where you can have two files in the root: > > www.whatever.com/yaml > www.whatever.com/yaml.Z > > Then you place the gem files in a subdirectory: > > www.whatever.com/gems/whatever.gem > > If you have a set of gem files that you want to host and you want to build > the yaml and yaml.Z file use the following code: > > require 'optparse' > require 'rubygems' > require 'zlib' > > Gem.manage_gems > > class Indexer > > def initialize(directory) > @directory = directory > end > > def gem_file_list > Dir.glob(File.join(@directory, "*.gem")) > end > > def build_index > File.open(File.join(@directory, "yaml"), "w") do |file| > file.puts "--- !ruby/object:Gem::Cache" > file.puts "gems:" > gem_file_list.each do |gemfile| > spec = Gem::Format.from_file_by_path(gemfile).spec > file.puts " #{spec.full_name}: #{spec.to_yaml.gsub(/\n/, "\n > ")[4..-1]}" > end > end > build_compressed_index > end > > def build_compressed_index > File.open(File.join(@directory, "yaml.Z"), "w") do |file| > file.write(Zlib::Deflate.deflate(File.read(File.join(@directory, > "yaml")))) > end > end > end > > ## > # > # Build index > # > # > > Indexer.new(".").build_index > > _______ > > If that code is to hard to extract from the email, let me know and I will > post it. Note that the directory that you pass in to the indexer is > location of the gem files. You need to chmod the yaml and yaml.Z files so > they are readable from a web client, yada yada yada. > > To use it you then do: > > gem install whatever.gem --source http://www.whatever.com > > Hope that helps, > > Rich > > On 3/24/05 8:56 AM, "James Britt" wrote: > > > Are there online docs for creating the YAML file needed when > > self-hosting gems? > > > > Thanks, > > > > James > > At risk of stating the obvious, If you don't mind running webrick, you can also just start up gem_server. -- Chad Fowler http://chadfowler.com http://rubycentral.org http://rubygarden.org http://rubygems.rubyforge.org (over 100,000 gems served!)