Welcome to day 32 of the 49 Days of Ruby! 🎉
Throughout the past 31 days we have worked quite a bit with Ruby gems. A gem is a packaged piece of code that you can incorporate into your code.
Ruby gems could help you with things like:
- web connections
- user management
- etc., etc., etc.
Did you know that all these gems are hosted in a central repository? They are! In a place called Rubygems.
Rubygems is supported and made possibly by the broader Ruby community.
Let's say you want to install the popular debugging gem
byebug on your computer. (We discussed
byebug on our debugging day.) To do so you'd run
gem install byebug from the command line. That command fetches the package from Rubygems and installs it locally.
Perhaps, you wish to install
byebug in your application. Inside the
Gemfile of your application you would have something like this:
source "https://rubygems.org" gem "byebug"
Then, from the command line you would run
bundle install and that would generate a
Gemfile.lock file that tells Ruby what version of
byebug you have installed, and would make it available to your application.
Every time you install a gem, be thankful for the great resource that is Rubygems!
Come back tomorrow for the next installment of 49 Days of Ruby! You can join the conversation on Twitter with the hashtag #49daysofruby.