Well, RubyConf 2003 is wrapped up and I am here at the Austin Airport with Chad Fowler and Jim Weirich. We had a great time...lots of great speakers, food and break-talks. On Friday we were there in a roundtable with Matz and someone brought up package management for Ruby (again!). Matz said if someone built a good one, he would include it in Ruby. So Chad, myself, Jim, David Black and Paul Brannan decided to just do it. We have two nights...let's build RubyGems!
We paired up and attacked the problem Friday night from 9 pm to 2 am, then a bit of discussion during the day on Saturday (and a bit of coding during the talks...shh), then Saturday night from 9 pm to 1 am and our results are up on RubyForge here.
We got an impressive start (code committed). We have Gem building, installation, uninstall, version support, dependency support, and apt-get like capability (for network installs). Of course, its really simple to use (thanks Ruby/Matz).
Here is a gemspec for Jabber4r:
require 'rubygems' spec = Gem::Specification.new do |s| s.add_dependency('rexml', '> 2.7.0') s.name = 'jabber4r' s.version = "0.5.0" s.platform = Gem::Platform::RUBY s.summary = "Jabber4r is a pure-Ruby Jabber client library" s.requirements << 'Jabber server' s.files = Dir.glob("lib/**/*").delete_if {|item| item.include?("CVS")} s.require_path = 'lib' s.autorequire = 'jabber4r/jabber4r' s.author = "Richard Kilmer" s.email = "[email protected]" s.rubyforge_project = "jabber4r" s.homepage = "http://jabber4r.rubyforge.org" end if $0==__FILE__ Gem::Builder.new(spec).build end
Pretty spiffy. You execute that with:
ruby jabber4r.gemspec Successfully built RubyGem Name: jabber4r Version: 0.5.0 File: jabber4r-0.5.0.gem
That generates the .gem file (with version) and you install like this:
sudo ruby jabber4r-0.5.0.gem Successfully installed jabber4r version 0.5.0
Then to use it:
irb -r rubygems > require_gem 'jabber4r' true
Gems manage the $LOAD_PATH of Ruby which lets two different versions of a Gem be installed and two scripts could each use the one they want. The gem --remote-install will be available once a service goes up on RubyForge. For now, you can serve Gems off of your machine to anyone on your local network.
I will post more about RubyConf soon.
Good stuff, Rich and company. Just sketched out the basic .gemspec file for FXRuby and it works as expected. Am I correct to assume that the stuff in a GEM should be restricted to "only the files needed to use this library (or extension)", and thus omits things like documentation files, test cases, etc.?
Anyways. Off to write a FOX GUI browser for these suckers.
Posted by: Lyle | Tuesday, November 18, 2003 at 01:42 PM
Lyle,
We plan to also include code to manage documentation and tests. So, unless things change, I would say that we plan to include everything that should come with a library--documents, tests, and all. I'm thinking we should have either separate meta-data indicating main test suite and/or a standard convention of where the file should be and what it should be called. It would be nice to be able to query which packages have tests and documentation in a respository.
Looking forward to seeing your browser!
Chad
Posted by: Chad | Wednesday, November 19, 2003 at 09:32 AM
Actually, we currently have the spec.files that holds all the library files...we could have a spec.docs which include those files. Those would be skipped during installation, but you could do:
gem --doc fxruby --output .
Or something to extract the documentation from the Gem. I will post this over as a potential enhancement on rubyforge project page.
Posted by: Rich | Wednesday, November 19, 2003 at 11:20 AM
And, as Rich and I discussed by phone earlier:
gem --test fxruby
..could run unit tests.
Or:
gem --install-strict fxruby
...could download all dependencies and refuse to install the packages unless their unit tests pass.
Posted by: Chad Fowler | Wednesday, November 19, 2003 at 10:40 PM
I'm sure you've been thinking about this already, but just in case... the project management that you've been planning for FreeRIDE should include support for RubyGems!
Posted by: Curt | Sunday, November 23, 2003 at 01:16 AM
How is rubygems dealing with installations which are not root, but local to a home directory? I noticed the use of sudo to install and no apparent way to specify install location. If this is just a feature that has been thought of but not yet implemented that's fine, but I just wanted to make sure the idea is being considered.
Posted by: Charles Comstock | Monday, December 22, 2003 at 05:16 AM
You can specify where to install Gems. There is a RUBY_GEMS ENV var that lists the directories (in order) to search in, and Gems are installed (by default) into the first directory listed. You can override that on Gem installation as well with a command line argument. You use 'sudo' only if installing into a 'system wide' path (/usr/local/lib/ruby..., etc). If your Ruby is installed locally, it will install within that path.
Posted by: Richard Kilmer | Wednesday, December 24, 2003 at 10:47 AM