Class | Gem::Specification |
In: |
lib/rubygems/specification.rb
|
Parent: | Object |
The Specification class contains the metadata for a Gem. Typically defined in a .gemspec file or a Rakefile, and looks like this:
spec = Gem::Specification.new do |s| s.name = 'example' s.version = '1.0' s.summary = 'Example gem specification' ... end
For a great way to package gems, use Hoe.
NONEXISTENT_SPECIFICATION_VERSION | = | -1 | The the version number of a specification that does not specify one (i.e. RubyGems 0.7 or earlier). | |
CURRENT_SPECIFICATION_VERSION | = | 3 |
The specification version applied to any new Specification instances created. This should
be bumped whenever something in the spec format changes.
Specification Version History: spec ruby ver ver yyyy-mm-dd description -1 <0.8.0 pre-spec-version-history 1 0.8.0 2004-08-01 Deprecated "test_suite_file" for "test_files" "test_file=x" is a shortcut for "test_files=[x]" 2 0.9.5 2007-10-01 Added "required_rubygems_version" Now forward-compatible with future versions 3 1.3.2 2009-01-03 Added Fixnum validation to specification_version |
name | [RW] | This gem‘s name |
require_paths | [RW] |
Paths in the gem to add to $LOAD_PATH when this gem is activated.
The default [‘lib’] is typically sufficient. |
rubygems_version | [RW] |
The version of RubyGems used to create this gem.
Do not set this, it is set automatically when the gem is packaged. |
specification_version | [RW] |
The Gem::Specification version of this
gemspec.
Do not set this, it is set automatically when the gem is packaged. |
summary | [R] |
A short summary of this gem‘s description. Displayed in `gem list
-d`.
The description should be more detailed than the summary. For example, you might wish to copy the entire README into the description. |
version | [R] | This gem‘s version |
loaded | -> | loaded? |
activated | -> | activated? |
activated | [RW] | True when this gemspec has been activated. This attribute is not persisted. |
autorequire | [RW] |
Autorequire was used by old RubyGems to automatically require a file.
Deprecated: It is neither supported nor functional. |
bindir | [RW] | The path in the gem for executable scripts. Usually ‘bin‘ |
cert_chain | [RW] | The certificate chain used to sign this gem. See Gem::Security for details. |
default_executable | [W] |
Sets the default executable for
this gem.
Deprecated: You must now specify the executable name to Gem.bin_path. |
description | [R] | A long description of this gem |
[RW] |
A contact email for this gem
If you are providing multiple authors and multiple emails they should be in the same order such that: Hash[*spec.authors.zip(spec.emails).flatten] Gives a hash of author name to email address. |
|
homepage | [RW] | The URL of this gem‘s home page |
loaded_from | [R] | Path this gemspec was loaded from. This attribute is not persisted. |
post_install_message | [RW] | A message that gets displayed after the gem is installed |
required_ruby_version | [R] | The version of ruby required by this gem |
required_rubygems_version | [R] | The RubyGems version required by this gem |
rubyforge_project | [RW] | The rubyforge project this gem lives under. i.e. RubyGems’ rubyforge_project is "rubygems". |
signing_key | [RW] | The key used to sign this gem. See Gem::Security for details. |
Returns all specifications. This method is discouraged from use. You probably want to use one of the Enumerable methods instead.
Sets the known specs to specs. Not guaranteed to work for you in the future. Use at your own risk. Caveat emptor. Doomy doom doom. Etc etc.
Set the directories that Specification uses to find specs. Setting this resets the list of known specs.
Returns every spec that matches name and optional requirements.
Find the best specification matching a name and requirements. Raises if the dependency doesn‘t resolve to a valid specification.
Search through all unresolved deps and sub-dependencies and return specs that contain the file matching path.
Special loader for YAML files. When a Specification object is loaded from a YAML file, it bypasses the normal Ruby object initialization routine (initialize). This method makes up for that and deals with gems of different ages.
input can be anything that YAML.load() accepts: String or IO.
Specification constructor. Assigns the default values to the attributes and yields itself for further initialization. Optionally takes name and version.
Activate this spec, registering it as a loaded spec and adding it‘s lib paths to $LOAD_PATH. Returns true if the spec was activated, false if it was previously activated. Freaks out if there are conflicts upon activation.
Activate all unambiguously resolved runtime dependencies of this spec. Add any ambigous dependencies to the unresolved list to be resolved later, as needed.
Returns an array with bindir attached to each executable in the executables list
Adds a development dependency named gem with requirements to this Gem. For example:
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.
Adds a runtime dependency named gem with requirements to this Gem. For example:
spec.add_runtime_dependency 'example', '~> 1.1', '>= 1.1.4'
Returns the full path to installed gem‘s bin directory.
NOTE: do not confuse this with bindir, which is just ‘bin’, not a full path.
The date this gem was created
Do not set this, it is set automatically when the gem is packaged.
The default executable for this gem.
Deprecated: The name of the gem is assumed to be the name of the executable now. See Gem.bin_path.
A list of Gem::Dependency objects this gem depends on.
Use add_dependency or add_development_dependency to add dependencies to a gem.
Return a list of all gems that have a dependency on this gemspec. The list is structured with entries that conform to:
[depending_gem, dependency, [list_of_gems_that_satisfy_dependency]]
Sets executables to value, ensuring it is an array. Don‘t use this, push onto the array instead.
Extensions to build when installing the gem. See Gem::Installer#build_extensions for valid values.
Sets extensions to extensions, ensuring it is an array. Don‘t use this, push onto the array instead.
Sets extra_rdoc_files to files, ensuring it is an array. Don‘t use this, push onto the array instead.
The default (generated) file name of the gem. See also spec_name.
spec.file_name # => "example-1.0.gem"
Returns the full path to the gems directory containing this spec‘s gem directory. eg: /usr/local/lib/ruby/1.8/gems
The directory that this gem was installed into. TODO: rename - horrible. this is the base_dir for a gem path
Normalize the list of files so that:
The platform this gem runs on. See Gem::Platform for details.
Setting this to any value other than Gem::Platform::RUBY or Gem::Platform::CURRENT is probably wrong.
Sets rdoc_options to value, ensuring it is an array. Don‘t use this, push onto the array instead.
Set requirements to req, ensuring it is an array. Don‘t use this, push onto the array instead.
Returns the full path to the directory containing this spec‘s gemspec file. eg: /usr/local/lib/ruby/gems/1.8/specifications
Returns the full path to this spec‘s gemspec file. eg: /usr/local/lib/ruby/gems/1.8/specifications/mygem-1.0.gemspec
The default name of the gemspec. See also file_name
spec.spec_name # => "example-1.0.gemspec"
Test files included in this gem. You cannot append to this accessor, you must assign to it.
Returns a Ruby code representation of this specification, such that it can be eval‘ed and reconstruct the same specification later. Attributes that still have their default values are omitted.
Returns a Ruby lighter-weight code representation of this specification, used for indexing only.
See to_ruby.
Recursively walk dependencies of this spec, executing the block for each hop.
Checks that the specification contains all required fields, and does a very basic sanity check.
Raises InvalidSpecificationException if the spec does not pass the checks..