Managing Required Gems on Rails Projects 17
We’re starting a new project and I’m finding myself adding things to the code base that we’ve done in the past… hence the last few posts. As we’re doing this, I’d like to highlight some of the little things that we do on each project to maintain some consistency and in that process reach out to the community for alternative approaches.
I’m intrigued by the vendor everything concept, but we haven’t yet adopted this on any of our projects (yet).
What we have been doing is to maintain a REQUIRED_GEMS file in the root directory of our Rails application.
For example:
$ cat REQUIRED_GEMS
actionmailer
actionpack
actionwebservice
activerecord
activesupport
cgi_multipart_eof_fix
daemons
fastercsv
fastthread
feedtools
gem_plugin
image_science
mongrel
mongrel_cluster
mysql
rails
rake
RedCloth
Ruby-MemCache
soap4r
uuidtools
Everybody on the team (designers/developers) knows to look here to make sure they have everything installed when beginning to work on the application.
This has worked fairly well from project to project but since we’re starting a new project, I’m curious if anybody has some better ways to approach this. Should we look more seriously at the vendor everything approach or are there any alternative approaches?
Get to Know a Gem: Rak 5
A few months ago, I posted about an article that showed you how to colorize your grep search results. Since then, I’ve heard people talking about ack, which describes itself as…
“a tool like grep, aimed at programmers with large trees of heterogeneous source code.”
It’s written in Perl, which is fine and dandy… but before I installed it, I heard that there was a Ruby version named rak, which describes itself as…
“a grep replacement in pure Ruby. It accepts Ruby syntax regular expressions and automatically recurses directories, skipping .svn/, .cvs/, pkg/ and more things you don’t care about. “
Sounds great. Let’s see what this thing can do.
Installing rak
Daniel Lucraft, the author of rak, was kind enough to package it up as a Rubygem. So, all we have to do is install it via gem install rak.
> sudo gem install rak
Password:
Bulk updating Gem source index for: http://gems.rubyforge.org
Successfully installed rak-0.8.0
Installing ri documentation for rak-0.8.0...
Installing RDoc documentation for rak-0.8.0...
~ >
Great, let’s move on.
Using rak
Now that it’s installed, we can use Rak by typing rak from the command line. You’d typically want to run this from within the root of your application.
For example, basic usage would look like the following.
$ rak search-pattern
In my first test, I ran rak README.

Immediately, I see a greater advantage to rak over using grep and that’s because it’s giving me line numbers for free, which takes remembering a few extra options with grep.
Like grep, we can specify a specific path to search with. For example, we use a view helper named link_to_unimplemented to help us track actions that aren’t implemented yet. Looking at a current project, I can run rak link_to_unimplemented app/views and produce the following results.

I’m going to keep playing with it, but wanted to help get the word out. If you have any tips on using it, please share them in the comments. :-)
Using MacPorts Ruby and Rails after Upgrading to OS X Leopard 15
If you previously followed my article, Installing Ruby on Rails and PostgreSQL on OS X, second edition and are now upgrading to OS X Leopard, you’ll want to make a few adjustments to your setup.
First of all, it’s great that Apple has decided to provide Ruby on Rails out of the box.
~ > gem list rails
*** LOCAL GEMS ***
rails (1.2.3)
Web-application framework with template engine, control-flow layer,
and ORM.
How many gems does it come with?
~ > gem list|grep '^[a-z]'|wc -l
29
It’s really great that Apple shipped Leopard pre-installed with 29 gems, especially if you don’t have your entire Rails stack setup already. In my case and for those that have followed my installation process, you don’t need to switch over to this new development stack (yet). I have a lot of time invested in my fully-functionaly MacPorts installation process (PostgreSQL, MySQL, RMagick, Subversion, Git, etc. Since this all working fine on my machine, I’m not ready to make the switch to Apple’s installation.
Don’t Fix it… if it’s not broken!
So, the the first thing that I did was modify my PATH environment variable, which has /usr/bin as the first path that it’ll look at when you try to run commands like ruby, mongrel_rails, gem, etc. You’ll want to modify this and prepend /opt/local/bin: to the front of PATH in your shell configuration. If you’re using bash, this would be… ~/.bashrc. If you’re using zshell like me, ~/.zshrc.
Now, when you start a new Terminal and run gem list, you’ll see all of the gems that you already have installed.
~ > gem list rails < new-host
*** LOCAL GEMS ***
rails (1.2.5, 1.2.4, 1.2.3, 1.1.6)
Web-application framework with template engine, control-flow layer,
and ORM.
Back to my happy gems…
~ > gem list|grep '^[a-z]'|wc -l < new-host
72
Great! Now I can get back to work and spend time playing with the new features in Finder, Mail.app, and iChat instead of installing all of the software dependencies that our development projects have. :-)
Gems Gone Wild! 1
Mike Clark is offering everyone1 in the Ruby community Mardis Gras beads… in exchange for showing everyone your sexy gems. Chad and Bryan showed us theirs, so I figured it was my turn to show you all what I’ve been hiding beneath this shell.
# gem list|grep '^[a-zA-Z]'
actionmailer (1.2.5)
actionpack (1.12.5)
actionwebservice (1.1.6)
activerecord (1.14.4)
activesupport (1.3.1)
asset_compiler (0.2)
BlueCloth (1.0.0)
builder (2.0.0)
camping (1.5)
capistrano (1.4.0, 1.3.1, 1.2.0)
capistrano-ext (1.1.0)
cgi_multipart_eof_fix (2.0.2)
cheat (1.2.1)
chronic (0.1.6)
color (0.1.0)
daemons (1.0.3, 0.4.4, 0.4.2)
diff-lcs (1.1.2)
facets (1.4.5)
fastercsv (1.2.0)
fastthread (0.6.2)
feedtools (0.2.26)
flexmock (0.5.0)
gem_plugin (0.2.2, 0.2.1)
gen (0.41.0)
glue (0.41.0)
google-geocode (1.2.1)
gruff (0.2.8)
hoe (1.1.6, 1.1.2)
hpricot (0.5.110, 0.4.86, 0.4, 0.2)
livejournal (0.3.1, 0.3.0)
markaby (0.5)
metaid (1.0)
mocha (0.4.0)
mongrel (1.0, 0.3.13.4, 0.3.13.3)
mongrel_cluster (0.2.1, 0.2.0)
needle (1.3.0)
net-ping (1.2.0)
net-sftp (1.1.0)
net-ssh (1.0.10)
nitro (0.41.0)
og (0.41.0)
payment (1.0.1)
piston (1.2.1)
postgres (0.7.1)
quickbooks (0.0.2)
rails (1.1.6)
rake (0.7.1)
rc-rest (2.1.0)
rcov (0.7.0.1)
RedCloth (3.0.4)
rmagick (1.14.1)
rspec (0.7.5, 0.7.4, 0.7.0, 0.6.4)
ruby-breakpoint (0.5.0)
ruby-growl (1.0.1)
rubyforge (0.3.2, 0.3.1)
RubyInline (3.6.2)
shipping (1.5.0)
sources (0.0.1)
superredcloth (1.160)
sydparse (1.2.0)
syntax (1.0.0)
tattle (1.0.1)
unicode (0.1)
uuidtools (1.0.0)
xml-simple (1.0.10, 1.0.9)
ZenTest (3.4.3, 3.4.1)
Perhaps it is time to run some updates. Been running off of Rails edge forever and never remember to update those gems. :-)
puts his new beads on…
1 Okay, maybe I lied about the free beads… ;-)
The PLANET ARGON dot ORG project and asset compiling gone wild
InfoQ recently unlaunched their new site that is dedicated to “tracking change and innovation in the enterprise software development community.” One of the first articles published on the site was written by Jeremy Voorhis, Lead Architect at PLANET ARGON. Jeremys’ article, Agile Asset Management with Ruby DSLs outlines an approach we took on a client project earlier this year for managing tons of assets for a Rails application. Our development team extracted this work and built asset_compiler, which is now available as a gem on RubyForge and we’ve recently setup a trac so you can post bugs, patches, and all things similar. We’ll be announcing a few more open source plugins, gems, and projects in the near future as well. I know that many of you are wondering when and where acts_as_legacy will show up… keep your eye on the trac. ;-)
To install asset_compiler, run:
gem install asset_compiler
Read the asset compiler documentation.
The PLANET ARGON dot org project
Enjoy!
RubyGems mirror to kill the wait 2
Like Dan Peterson, I have setup a mirror of the RubyGems repository on the same server that is an official RubyForge mirror.
http://rubyforge.planetargon.com/gems.rubyforge.org
gem install --source http://rubyforge.planetargon.com/gems.rubyforge.org postgres
The RubyForge mirror team is working on a gem mirroring solution… and in the meantime, this is my attempt to help out with the load.
Dan also noted that you could modify the .gemrc file:
gem: --source http://rubyforge.planetargon.com/gems.rubyforge.orgThanks Danp for pointing this out… and Enjoy!




