`

rubygems.org guides 翻译九(参考规范)

    博客分类:
  • gem
阅读更多

The Specification class 包含一个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/gems/example'
end

 

从rubygems2.0开始,说明中可以包含任意的metadata,一些 metadata for restrictions(限制) on the format and size of metadata items you may add to a specification.

目录:

一、必须的gemspec属性

二、推荐的gemspec属性

三、可选的gemspec属性

=======================================================================

一、必须的gemspec属性

author=(o)

Singular writer for authors

Usage:

spec.author = 'John Jones'

 

authors=(value)

列出所有作者,必须是一个数组。

Usage:

spec.authors = ['John Jones', 'Mary Smith']

 

files

Files included in this gem. You cannot append to this accessor, you must assign to it.

Only add files you can require to this list, not directories, etc.

Directories are automatically stripped from this list when building a gem, other non-files cause an error.

Usage:

require 'rake'
spec.files = FileList['lib     .rb',
                      'bin/*',
                      '[A-Z]*',
                      'test/   *'].to_a

# or without Rake...
spec.files = Dir['lib/   *.rb'] + Dir['bin/*']
spec.files += Dir['[A-Z]*'] + Dir['test/**/*']
spec.files.reject! { |fn| fn.include? "CVS" }

 

name

该gem的名字

Usage:

spec.name = 'rake'

 

platform=(platform)

该gem运行平台

This is usually Gem::Platform::RUBY or Gem::Platform::CURRENT.

Most gems contain pure Ruby code; they should simply leave the default value in place. Some gems contain C (or other) code to be compiled into a Ruby “extension”. The should leave the default value in place unless their code will only compile on a certain type of system. Some gems consist of pre-compiled code (“binary gems”). It's especially important that they set the platform attribute appropriately. A shortcut is to set the platform to Gem::Platform::CURRENT, which will cause the gem builder to set the platform to the appropriate value for the system on which the build is being performed.

If this attribute is set to a non-default value, it will be included in the filename of the gem when it is built such as: nokogiri-1.6.0-x86-mingw32.gem

Usage:

spec.platform = Gem::Platform.local

 

require_paths=(val)

Paths in the gem to add to $LOAD_PATH when this gem is activated.

See also require_paths

If you have an extension you do not need to add "ext" to the require path, the extension build process will copy the extension files into “lib” for you.

The default value is "lib"

Usage:

# If all library files are in the root directory...
spec.require_paths = ['.']

 

rubygems_version

The version of RubyGems used to create this gem.

Do not set this, it is set automatically when the gem is packaged.

 

summary

A short summary of this gem's description. Displayed in `gem list -d`.

The description should be more detailed than the summary.

Usage:

spec.summary = "This is a small summary of my gem"

 

version

This gem's version.

The version string can contain numbers and periods, such as 1.0.0. A gem is a 'prerelease' gem if the version has a letter in it, such as 1.0.0.pre.

Usage:

spec.version = '0.4.1'

二、推荐的gemspec属性

license=(o)

The license for this gem.

The license must be no more than 64 characters.

This should just be the name of your license. The full text of the license should be inside of the gem (at the top level) when you build it.

The simplest way, is to specify the standard SPDX ID spdx.org/licenses/ for the license. Ideally you should pick one that is OSI (Open Source Initiative) opensource.org/licenses/alphabetical approved.

The most commonly used OSI approved licenses are BSD-3-Clause and MIT. GitHub also provides a license picker atchoosealicense.com/.

You should specify a license for your gem so that people know how they are permitted to use it, and any restrictions you're placing on it. Not specifying a license means all rights are reserved; others have no rights to use the code for any purpose.

You can set multiple licenses with licenses=

Usage:

spec.license = 'MIT'

 

licenses=(licenses)

The license(s) for the library.

Each license must be a short name, no more than 64 characters.

This should just be the name of your license. The full text of the license should be inside of the gem when you build it.

See license= for more discussion

Usage:

spec.licenses = ['MIT', 'GPL-2']

 

三、可选的gemspec属性

add_development_dependency(gem*requirements)

Adds a development dependency named gem with requirements to this gem.

Usage:

spec.add_development_dependency 'example', '~> 1.1', '>= 1.1.4'

Development dependencies aren't installed by default and aren't activated when a gem is required.

 

add_runtime_dependency(gem*requirements)

Adds a runtime dependency named gem with requirements to this gem.

Usage:

spec.add_runtime_dependency 'example', '~> 1.1', '>= 1.1.4'

 

bindir

可执行脚本的路径,通常是 'bin'

Usage:

spec.bindir = 'bin'

 

cert_chain

The certificate chain used to sign this gem. See Gem::Security for details.

 

description

该gem的一个详细的描述

The description should be more detailed than the summary but not excessively long. A few paragraphs is a recommended length with no examples or formatting.

Usage:

spec.description = <<-EOF
  Rake is a Make-like program implemented in Ruby. Tasks and
  dependencies are specified in standard Ruby syntax.
EOF

 

email

该gem的联系邮箱

Usage:

spec.email = 'john.jones@example.com'
spec.email = ['jack@example.com', 'jill@example.com']

 

executables

Executables included in the gem.

For example, the rake gem has rake as an executable. You don’t specify the full path (as in bin/rake); all application-style files are expected to be found in bindir. These files must be executable Ruby files. Files that use bash or other interpreters will not work.

Executables included may only be ruby scripts, not scripts for other languages or compiled binaries.

Usage:

spec.executables << 'rake'

 

extensions

Extensions to build when installing the gem, specifically the paths to extconf.rb-style files used to compile extensions.

These files will be run when the gem is installed, causing the C (or whatever) code to be compiled on the user’s machine.

Usage:

spec.extensions << 'ext/rmagic/extconf.rb'

See Gem::Ext::Builder for information about writing extensions for gems.

 

extra_rdoc_files

Extra files to add to RDoc such as README or doc/examples.txt

When the user elects to generate the RDoc documentation for a gem (typically at install time), all the library files are sent to RDoc for processing. This option allows you to have some non-code files included for a more complete set of documentation.

Usage:

spec.extra_rdoc_files = ['README', 'doc/user-guide.txt']

 

homepage

The URL of this gem's home page

Usage:

spec.homepage = 'http://rake.rubyforge.org'

 

metadata

:attr_accessor: metadata

The metadata holds extra data for this gem that may be useful to other consumers and is settable by gem authors without requiring an update to the rubygems software.

Metadata items have the following restrictions:

  • The metadata must be a Hash object

  • All keys and values must be Strings

  • Keys can be a maximum of 128 bytes and values can be a maximum of 1024 bytes

  • All strings must be UTF-8, no binary data is allowed

To add metadata for the location of a issue tracker:

s.metadata = { "issue_tracker" => "https://example/issues" }

 

post_install_message

A message that gets displayed after the gem is installed.

Usage:

spec.post_install_message = "Thanks for installing!"

 

rdoc_options

Specifies the rdoc options to be used when generating API documentation.

Usage:

spec.rdoc_options << '--title' << 'Rake -- Ruby Make' <<
  '--main' << 'README' <<
  '--line-numbers'

 

required_ruby_version

The version of Ruby required by this gem

 

required_ruby_version=(req)

The version of Ruby required by this gem. The ruby version can be specified to the patch-level:

$ ruby -v -e 'p Gem.ruby_version'
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0]
#<Gem::Version "2.0.0.247">

Usage:

# This gem will work with 1.8.6 or greater...
spec.required_ruby_version = '>= 1.8.6'

# Only with ruby 2.0.x
spec.required_ruby_version = '~> 2.0'

 

required_rubygems_version

The RubyGems version required by this gem

 

required_rubygems_version=(req)

The RubyGems version required by this gem

 

requirements

Lists the external (to RubyGems) requirements that must be met for this gem to work. It's simply information for the user.

Usage:

spec.requirements << 'libmagick, v6.0'
spec.requirements << 'A good graphics card'

 

signing_key

用来签名gem,详述请看 Gem::Security 

 

 

 

 

 

分享到:
评论

相关推荐

    gemstash, 一个 RubyGems.org 缓存和 private gem 服务器.zip

    gemstash, 一个 RubyGems.org 缓存和 private gem 服务器 什么是 Gemstash?Gemstash是远程服务器( 如 https://rubygems.org ) 和 private gem 源的缓存。在你的控制范围内,如果你使用的是多个可以访问服务器的...

    rubygems-update-3.1.3.gem

    A package (also known as a library) contains a set of functionality that can be invoked by a Ruby program, such as reading and parsing an XML ... See our guide on publishing a Gem at guides.rubygems.org

    meg:帮助管理和支持 RubyGems.org 的快速命令

    帮助管理和支持 RubyGems.org 的快速命令。 目前帮助通过 SSH 连接到 RubyGems.org 基础设施和运行命令。 安装 $ cd $ git clone git://github.com/rubygems/meg.git .meg 对于 bash 用户: $ echo 'eval "$($...

    Ruby Toolbox data on Rubygems.org-crx插件

    在Rubygems.org上查看Ruby Toolbox数据 此Chrome扩展程序从Ruby工具箱(https://www.ruby-toolbox.com/)中提取信息,以显示在rubygems.org上。 例如,如果您正在https://rubygems.org/gems/simplecov上查看诸如...

    adoption.rubygems.org

    option.rubygems.org 项目导师的姓名: Nick Quaranto,Benjamin Fleischer 项目团队的名称:丽娜·托雷斯(Lina Torres)的安吉拉(Angela Guette) 项目名称: RubyGems.org采用中心 网址: : 关于该项目: ...

    rubygems.org:Ruby社区的gem托管服务

    RubyGems.org(néeGemcutter) Ruby社区的gem主机。 目的 提供更好的API处理宝石 创建更透明,更易于访问的项目页面 使社区能够改善和增强网站 支持 由管理, 是一个社区资助的组织,通过门票和赞助为和的会议...

    rubygems.org-backup:这是历史重写之前 ruby​​gems.org 的 BACKUP 存储库。 不使用。 请不要拉请求

    RubyGems.org(姓氏 Gemcutter) Ruby 社区的 Gem 托管。目的提供更好的 API 来处理 gems 创建更透明和可访问的项目页面使社区能够改进和增强站点链接 :#rubygems 在 Freenode 上: : :贡献请遵循我们的。 要进行...

    2.4-3.0.rubygems.rar

    gem包管理

    rubygems-incident-verifiers

    ##概括此处提供的工具使您能够将 gem 的本地副本与 Rubygems.org 上的副本进行检查。 这些工具旨在让 gem 开发人员根据 Rubygems.org 服务器检查他们的本地开发副本(为什么?请参阅文档末尾的注释)。 目前正在...

    rubygems-1.8.7.gz for linux

    rubygems-1.8.7.gz rubygems-1.8.7.gz

    曲柄的Rubygems「Crank for Rubygems」-crx插件

    ★导航至ruby gem的GitHub或Rubygems.org页面。 在GitHub上打开'Gemfile'或'.gemspec'文件,然后单击任何gem名称。 您将被重定向到gem项目页面。 ★从上下文菜单中打开RubyGems.org中的ruby gem页面。 用鼠标突出...

    rubygems-master-(1).zip_GEM

    Download from: rubygems.org/pages/download Unpack into a directory and cd there Install with: ruby setup.rb # you may need admin/root privilege For more details and other options, see: ruby setup....

    guides:努力为RubyGems生态系统提供出色的文档

    从rubygems.org/pages/docs移植内容 从help.rubygems.org知识库移植内容 在这里找到许多StackOverflow / ruby​​-talk问题并获得其常见答案 填写更多指南! 设置 确保已gem install jekyll ( gem install jekyll ...

    RubyGems.txt

    RubyGems

    gemstash:RubyGems.org缓存和私有gem服务器

    今天或什至更好的做出贡献,并确保Bundler,RubyGems,Gemstash和其他共享工具在未来数年内都存在。 快速入门指南 设置 Gemstash旨在快速,轻松地进行设置。 到本《快速入门指南》结束时,您将能够将公共资源中的...

    rubygems-3.2.12.tgz

    rubygems-3.2.12.tgz

    rubygems-2.7.4.tgz

    rubygems-2.7.4.tgz centos6.5安装redmine时需要的软件包

    Crank for Rubygems-crx插件

    ★导航到ruby gem的github或rubygems.org页面。 在github上打开'gemfile'或'.gemspec'文件,然后单击任何宝石名称。 您将被重定向到GEM项目页面。 ★从上下文菜单中打开RubyGems.org中的Ruby Gem页面。 在使用鼠标的...

Global site tag (gtag.js) - Google Analytics