Ruby and Her Gems

Ashray Sudhir
Jul 10, 2017 · 2 min read

Ruby depends on many of her friends which she lovingly refers to as her precious little “gems”. A gem is nothing but a ruby code which we extract for later use. “Gemfiles” are the files which we create and use for describing the dependencies of a ruby program on the gems. This Gemfile in turn is treated and evaluated as a ruby code. Ruby likes to keep her friends close and Gemfiles help her do that.

The gemfile must always be present in the root of the project directory. “Bundler” is a manager for Ruby which installs the exact gems and their versions when required. All one needs to do is execute just one commands bundle install from the root of the project directory and voila!, Ruby has been reunited with her gems. Once this is done, a file named “Gemfile.lock” gets created which records the exact versions of the gems which were installed. This file can then be reused later to conform to the same specifications.

The first thing one needs to do is inform the Gemfile where it needs to look for the required gems. This is called the source and it must be a valid Rubygems repository. The most used one is https://rubygems.org. RubyGems.org is maintained by “Ruby Together” which is a grassroots initiative committed to supporting the Ruby infrastructure. The name of the gems which are required and then specified in the file. It is also possible to give the version & source details of each gem too.

Ruby is really effective when she is alone but when she teams up with her gems, she gets added enthusiasm which really kicks up her productivity.

Written by

Passionately Curious Always! :)

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade