Gemspec Files

suggest change

Each 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.

  1. Use underscores, NO SPACES
  2. Use only lowercase letters
  3. Use hyphens for an extension gem (if the gem is example, an extension is example-extension) so it can be required as require "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.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents