1. Gem::
  2. BasicSpecification

class Gem::BasicSpecification

BasicSpecification is an abstract class which implements some common code used by both Specification and StubSpecification.

Attributes

loaded_from[RW]

The path this gemspec was loaded from. This attribute is not persisted.

Public Class Methods

Source
# File lib/rubygems/basic_specification.rb, line 37defself.default_specifications_dirGem.default_specifications_dirend
Source
# File lib/rubygems/basic_specification.rb, line 33definitializeinternal_initend

Public Instance Methods

Source
# File lib/rubygems/basic_specification.rb, line 57defactivated?raiseNotImplementedErrorend

True when the gem has been activated

Source
# File lib/rubygems/basic_specification.rb, line 66defbase_dirraiseNotImplementedErrorend

Returns the full path to the base gem directory.

eg: /usr/local/lib/ruby/gems/1.8

Source
# File lib/rubygems/basic_specification.rb, line 116defbase_dir_priority(gem_path)gem_path.index(base_dir)||gem_path.sizeend

Gems higher up ingem_path take precedence

Source
# File lib/rubygems/basic_specification.rb, line 73defcontains_requirable_file?(file)ifignored?ifplatform==Gem::Platform::RUBY||Gem::Platform.local===platformwarn"Ignoring #{full_name} because its extensions are not built. " \"Try: gem pristine #{name} --version #{version}"endreturnfalseendis_soext =file.end_with?(".so",".o")ifis_soexthave_file?file.delete_suffix(File.extname(file)),Gem.dynamic_library_suffixeselsehave_file?file,Gem.suffixesendend

Return true if this spec can requirefile.

Source
# File lib/rubygems/basic_specification.rb, line 197defdatadir# TODO: drop the extra ", gem_name" which is uselessly redundantFile.expand_path(File.join(gems_dir,full_name,"data",name))end

The path to the data directory for this gem.

Source
# File lib/rubygems/basic_specification.rb, line 101defdefault_gem?!loaded_from.nil?&&File.dirname(loaded_from)==Gem.default_specifications_dirend
Source
# File lib/rubygems/basic_specification.rb, line 109defdefault_gem_prioritydefault_gem??1:-1end

Regular gems take precedence over default gems

Source
# File lib/rubygems/basic_specification.rb, line 123defextension_dir@extension_dir||=File.expand_path(File.join(extensions_dir,full_name))end

Returns full path to the directory where gem’s extensions are installed.

Source
# File lib/rubygems/basic_specification.rb, line 130defextensions_dirGem.default_ext_dir_for(base_dir)||File.join(base_dir,"extensions",Gem::Platform.local.to_s,Gem.extension_api_version)end

Returns path to the extensions directory.

Source
# File lib/rubygems/basic_specification.rb, line 147deffull_gem_path@full_gem_path||=find_full_gem_pathend

The full path to the gem (install path + full name).

TODO: This is duplicated withgem_dir. Eventually either of them should be deprecated.

Source
# File lib/rubygems/basic_specification.rb, line 156deffull_nameifplatform==Gem::Platform::RUBY||platform.nil?"#{name}-#{version}"else"#{name}-#{version}-#{platform}"endend

Returns the full name (name-version) of thisGem. Platform information is included (name-version-platform) if it is specified and not the default Ruby platform.

Source
# File lib/rubygems/basic_specification.rb, line 169deffull_name_with_locationifbase_dir!=Gem.dir"#{full_name} in #{base_dir}"elsefull_nameendend

Returns the full name of thisGem (see ‘Gem::BasicSpecification#full_name`). Information about where the gem is installed is also included if not installed in the default GEM_HOME.

Source
# File lib/rubygems/basic_specification.rb, line 181deffull_require_paths@full_require_paths||=beginfull_paths =raw_require_paths.mapdo|path|File.joinfull_gem_path,pathendfull_paths<<extension_dirifhave_extensions?full_pathsendend

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

Source
# File lib/rubygems/basic_specification.rb, line 229defgem_dir@gem_dir||=find_full_gem_pathend

Returns the full path to this spec’s gem directory. eg: /usr/local/lib/ruby/1.8/gems/mygem-1.0

TODO: This is duplicated withfull_gem_path. Eventually either of them should be deprecated.

Source
# File lib/rubygems/basic_specification.rb, line 237defgems_dirraiseNotImplementedErrorend

Returns the full path to the gems directory containing this spec’s gem directory. eg: /usr/local/lib/ruby/1.8/gems

Source
# File lib/rubygems/basic_specification.rb, line 95defignored?return@ignoredunless@ignored.nil?@ignored =missing_extensions?end

Return true if this spec should be ignored because it’s missing extensions.

Source
# File lib/rubygems/basic_specification.rb, line 334deflib_dirs_globdirs =ifraw_require_pathsifraw_require_paths.size>1"{#{raw_require_paths.join(",")}}"elseraw_require_paths.firstendelse"lib"# default value for require_paths for bundler/inlineend"#{full_gem_path}/#{dirs}"end

Returns a string usable inDir.glob to match all requirable paths for this spec.

Source
# File lib/rubygems/basic_specification.rb, line 317defmatches_for_glob(glob)# TODO: rename?glob =File.join(lib_dirs_glob,glob)Dir[glob]end

Return all files in this gem that match forglob.

Source
# File lib/rubygems/basic_specification.rb, line 251defnameraiseNotImplementedErrorend

Name of the gem

Source
# File lib/rubygems/basic_specification.rb, line 258defplatformraiseNotImplementedErrorend

Platform of the gem

Source
# File lib/rubygems/basic_specification.rb, line 326defpluginsmatches_for_glob("rubygems#{Gem.plugin_suffix_pattern}")end

Returns the list of plugins in this spec.

Source
# File lib/rubygems/basic_specification.rb, line 290defrequire_pathsreturnraw_require_pathsunlesshave_extensions?  [extension_dir].concatraw_require_pathsend

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_path ='.'
Source
# File lib/rubygems/basic_specification.rb, line 300defsource_pathspaths =raw_require_paths.dupifhave_extensions?ext_dirs =extensions.mapdo|extension|extension.split(File::SEPARATOR,2).firstend.uniqpaths.concatext_dirsendpaths.uniqend

Returns the paths to the source files for use with analysis and documentation tools. These paths are relative to full_gem_path.

Source
# File lib/rubygems/basic_specification.rb, line 366defstubbed?raiseNotImplementedErrorend

Whether this specification is stubbed - i.e. we have information about the gem from a stub line, without having to evaluate the entire gemspec file.

Source
# File lib/rubygems/basic_specification.rb, line 370defthisselfend
Source
# File lib/rubygems/basic_specification.rb, line 209defto_fullpath(path)ifactivated?@paths_map||= {}Gem.suffixes.eachdo|suf|full_require_paths.eachdo|dir|fullpath ="#{dir}/#{path}#{suf}"nextunlessFile.file?(fullpath)@paths_map[path]||=fullpathendend@paths_map[path]endend

Full path of the target library file. If the file is not in this gem, return nil.

Source
# File lib/rubygems/basic_specification.rb, line 351defto_specraiseNotImplementedErrorend

Return aGem::Specification from this gem

Source
# File lib/rubygems/basic_specification.rb, line 358defversionraiseNotImplementedErrorend

Version of the gem

Private Instance Methods

Source
# File lib/rubygems/basic_specification.rb, line 376defhave_extensions?!extensions.empty?end
Source
# File lib/rubygems/basic_specification.rb, line 380defhave_file?(file,suffixes)returntrueifraw_require_paths.any?do|path|base =File.join(gems_dir,full_name,path,file)suffixes.any? {|suf|File.file?base+suf }endifhave_extensions?base =File.joinextension_dir,filesuffixes.any? {|suf|File.file?base+suf }elsefalseendend