gem dependency gem_name to get a list of dependencies of a gem. For instance, running :
$ gem dependency capistrano
Gives the following output:
highline (>= 0)
mocha (= 0.9.12, development)
net-scp (>= 1.0.0)
net-sftp (>= 2.0.0)
net-ssh (>= 2.0.14)
net-ssh-gateway (>= 1.1.0)
2. Follow the Rails Core Team members Twitter feed.
3. Talk to other developers and ask what gems they have used in their projects.
4. Subscribe to Ruby podcasts, blogs.
I was working on a Rails project that was having a giant if-else statements to recognize the mime-types of a given file for uploading to Amazon S3. I was looking at Gemfile.lock and used tip #1 above to find the mime-types and read more about the gem on github. I was able to replace my custom mime-type recognition code with the mime-types gem. If you run:
$ gem dependency mime-types
you will see only development dependencies on other gems, there are no runtime dependency on any other gems. This gem is self-contained and is a good unit of reuse.
It's like using small Unix utility to compose and solve many different problems. The only dependency it might have is that it works only on certain versions of Ruby.
Things to Consider When Evaluating Gems
1. Simplicity vs Flexibility
There is a trade-off between simplicity and flexibility. For instance for file uploading you could use many gems like fog, carrierwave etc and create lot dependencies in your code that provides ease of switching between libraries - flexibility. But it complicates your codebase and simplicity is lost. You will also have more work during upgrade of your project because of these dependencies.
Can I write this by myself in a simpler way that is easier to manage? Read the source code of the gem to make your own decision about reuse or develop on your own.
3. Support and Maintenance
- Is there any critical bugs that is not being addressed by anyone?
- Is the source code easy to read and modify for your needs?
- Are the developers active and keep up with upgrading the gem as new Ruby versions are released?