7. Creating Your Own Gem
This is a skimpy overview; see the DeveloperGuide for the real meat.
Let’s say we have a package called ’’mygem’’ which is at version 2.1.
Building a gem involves two steps:
- creating a gem specification file (mygem.gemspec), which is Ruby code; and
- running gem build mygem.gemspec to create the gem file (mygem-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.