7. Creating Your Own Gem
7.1 Building a gem
This is a skimpy overview; see the DeveloperGuide for the real meat.
Let’s say we have a package called ’’rmagic’’ which is at version 2.1.
Building a gem involves two steps:- creating a gem specification file (rmagic.gemspec), which is Ruby code; and
- running gem build my.gemspec to create the gem file (rmagic-2.1.gem)
The specification contains Ruby code to create a Gem::Specification object, which defines all of the information we saw above in Looking at an installed gem.
The gem file contains everything needed to install itself on another computer, including the specification and all the file data.
See? Building a gem is very easy!
Note: rake (http://rake.rubyforge.org) is a big help in creating gem files in a project setting, where the version number is always changing, etc.