Ruby Gems: What I’ve learned so far

What is a gem?
Simply put, a gem is a package that wraps a file or set of files (like an application).

Why use a gem?
Gems are a convenient way to share software. One popular gem is Rspec, the tool I use for doing unit tests in Ruby. I recently turned my tic tac toe game into a gem in order to share it more easily.

How do you make a gem?
In order to turn my game into a gem I had to create a .gemspec file. This file specifies (hence the spec in the filetype) the contents and labeling of the gem. For a more in-depth tutorial on how to create a gem, rubygems.org is a great resource.

How do you use a gem?
Before today, if you wanted to play my game you had to use Github to access my repository, clone that repository onto your machine, enter 'chmod +x bin/tictactoe', then enter 'bin/tictactoe' to start things up. The steps now, assuming you have Ruby 1.9 or higher installed:

1.) In your terminal, enter ‘gem install pszals_ttt’. This will cause RubyGems (the package manager for Ruby) to look at the RubyGems that are hosted online, pull the gem named ‘pszals_ttt’ and install it onto your machine. The gem is now playable and accessible from your command line.
2.) Start irb
3.) Enter "require 'runner'"
4.) Enter ‘Runner.new(Console_UI.new).call’
5.) Follow the instructions to play a game of tic tac toe against a friend, computer, or yourself!