Gemspec Files
suggest changeEach gem has a <gem name>.gemspec file with metadata about the gem and its files. The shape of a gemspec is:
Gem::Specification.new do |s|
# Details about gem. They are added in the format:
s.<detail name> = <detail value>
end
The fields required by RubyGems are:
Either author = string or authors = array
Use author = for one author and authors = for several. authors is an array of names.
files = array
files lists every file that ships in the gem. Paths are relative to the gem root, not the filesystem root. If the files are under lib/, Dir["lib/**/*"] lists them. Dir["/lib/"] does not: that looks at /lib on the machine.
name = string
Here string is just the name of your gem. Rubygems recommends a few rules you should follow when naming your gem.
- Use underscores, NO SPACES
- Use only lowercase letters
- Use hyphens for an extension gem (if the gem is
example, an extension isexample-extension) so it can be required asrequire "example/extension".
RubyGems also adds “If you publish a gem on rubygems.org it may be removed if the name is objectionable, violates intellectual property or the contents of the gem meet these criteria. You can report such a gem on the RubyGems Support site.”
platform=
Which platforms this gem runs on. Pure Ruby gems leave this at the default, Gem::Platform::RUBY.
require_paths=
Directories added to $LOAD_PATH when the gem is activated. The default is ["lib"].
summary= string
A short summary of what the gem does.
version= string
The current version number of the gem.
The recommended fields are:
email = string
An email address that will be associated with the gem.
homepage= string
The website where the gem lives.
Either license= or licenses=
An SPDX identifier such as "MIT", or an array of them in licenses.