From: Marc Heiler Date: 2011-07-17T03:55:14+09:00 Subject: Re: Anyone interested in a Package Manager in Ruby? To Brian, > Have you compared your scripts against homebrew? > http://mxcl.github.com/homebrew/ I had some time to look at homebrew. First, at #homebrew. Well ... 42 people ... no reply to a question I asked. :( So I went to the site and noticed they used Github. This is GREAT. They have a structure with about 1600 formulas. A formula is a ruby file which looks like this: https://github.com/mxcl/homebrew/blob/master/Library/Formula/simh.rb It uses methods to convey the information: url 'http://simh.trailing-edge.com/sources/simhv38-1.zip' version '3.8-1' homepage 'http://simh.trailing-edge.com/' md5 'e15f65a82e21ea49e14b438326d93d5c' url method probably points to the URL of the program where you can download it ... homepage provides some information ... md5 the md5sum I suppose... version may be something internal, or whatever. The -1 part at the version is probably a revision number. I am unhappy with the choice to store the data in pure ruby though. I feel the data should be ideally decoupled from any language. Take https://github.com/mxcl/homebrew/blob/master/Library/Formula/a2ps.rb You have boilerplate code there: require 'formula' class A2ps < Formula Perhaps I am too stringent on purity but to me it feels like a suboptimal solution. The same could be achieved by a bit of metaprogramming. The class name derives from the file name.rb anyway ... The main script seems to be at: https://github.com/mxcl/homebrew/blob/master/Library/Homebrew/formula.rb There is another thing I don't understand. This could work on *nix systems just as easily. Just compile into a standalone directory, register the files there, and symlink or copy them into the FHS directory try. Why does homebrew want to be known as only Mac OS usable? I don't quite understand that. There are some interesting strategies used in formula.rb though. For instance, they bundle different download strategies together: VCS_SYMBOLS = { :bzr => BazaarDownloadStrategy, :curl => CurlDownloadStrategy, :cvs => CVSDownloadStrategy, :git => GitDownloadStrategy, :hg => MercurialDownloadStrategy, :nounzip => NoUnzipCurlDownloadStrategy, :post => CurlPostDownloadStrategy, :svn => SubversionDownloadStrategy, } def initialize(url, specs = nil) unless specs.nil? # Get download strategy hint, if any @using = specs.delete :using detected = VCS_SYMBOLS[@using] I found this nice. Never thought of a fairly complete download strategy yet, especially not :post or :nounzip haha :D -- Posted via http://www.ruby-forum.com/.