class Gem::Specification

Specification 类包含 gem 的信息。通常定义在 .gemspec 文件或 Rakefile 中,如下所示

Gem::Specification.new do |s|
  s.name        = 'example'
  s.version     = '0.1.0'
  s.licenses    = ['MIT']
  s.summary     = "This is an example!"
  s.description = "Much longer explanation of the example!"
  s.authors     = ["Ruby Coder"]
  s.email       = 'rubycoder@example.com'
  s.files       = ["lib/example.rb"]
  s.homepage    = 'https://rubygems.org.cn/gems/example'
  s.metadata    = { "source_code_uri" => "https://github.com/example/example" }
end

从 RubyGems 2.0 开始,Specification 可以保存任意元数据。有关您可以添加到规范的元数据项的格式和大小限制,请参阅 metadata