-
Notifications
You must be signed in to change notification settings - Fork 2
Create Your Gem Project
Miliox edited this page Apr 21, 2013
·
1 revision
A RubyGem is a software package, commonly called a “gem”. Gems contain a packaged Ruby application or library. The RubyGems software itself allows you to easily download, install, and manipulate gems on your system.
Each gem has a name, version and platform. They are used to split out reusable functionality so others can use.
- Code (include test and utils)
- Documentation
- gemspec
Gems follow the same standard structure of code organization:
% tree mygem
mygem/
├── bin/
│ └── mygem
├── lib/
│ └── mygem.rb
├── test/
│ └── test_mygem.rb
├── README
├── Rakefile
└── mygem.gemspec
The major components of a gem:
- lib directory with source code
- test or spec for tests
- Rakefile for automation of test, generate code and other tasks
- bin with a executable file that is installed in PATH
- Documentation is usually included in the README and inline with the code (RDocs or YARD)
- gemspec contains information about the gem.
Use to document details about the gem, who made, what the purpose, dependencies, authors and other information.
$ cat mygem.gemspec
Gem::Specification.new do |s|
s.name = 'mygem'
s.version = '1.0.0'
s.date = '2013-04-20'
s.summary = "My Gem!"
s.description = "My Gem is a Gem!"
s.authors = ["Emiliano Firmino"]
s.email = 'emiliano.firmino@gmail.com'
s.homepage = 'http://mypage.com.br'
s.files = ["lib/mygem.rb"]
end
See RailsCasts #245: New gem with Bundler
How to Create a Gem From Scratch With Bundler
How To Start Writing a Ruby Gem
Make Your Own Gem
Making Ruby Gems
RailsCasts #245: New gem with Bundler
What Is a Gem