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 |
loaded | -> | loaded? |
True if this gem was loaded from disk | ||
== | -> | eql? |
loaded | [RW] | true when this gemspec has been loaded from a specifications directory. This attribute is not persisted. |
loaded_from | [RW] | Path this gemspec was loaded from. This attribute is not persisted. |
Load custom marshal format, re-initializing defaults as needed
# File lib/rubygems/specification.rb, line 197 197: def self._load(str) 198: array = Marshal.load str 199: 200: spec = Gem::Specification.new 201: spec.instance_variable_set :@specification_version, array[1] 202: 203: current_version = CURRENT_SPECIFICATION_VERSION 204: 205: field_count = if spec.specification_version > current_version then 206: spec.instance_variable_set :@specification_version, 207: current_version 208: MARSHAL_FIELDS[current_version] 209: else 210: MARSHAL_FIELDS[spec.specification_version] 211: end 212: 213: if array.size < field_count then 214: raise TypeError, "invalid Gem::Specification format #{array.inspect}" 215: end 216: 217: spec.instance_variable_set :@rubygems_version, array[0] 218: # spec version 219: spec.instance_variable_set :@name, array[2] 220: spec.instance_variable_set :@version, array[3] 221: spec.instance_variable_set :@date, array[4] 222: spec.instance_variable_set :@summary, array[5] 223: spec.instance_variable_set :@required_ruby_version, array[6] 224: spec.instance_variable_set :@required_rubygems_version, array[7] 225: spec.instance_variable_set :@original_platform, array[8] 226: spec.instance_variable_set :@dependencies, array[9] 227: spec.instance_variable_set :@rubyforge_project, array[10] 228: spec.instance_variable_set :@email, array[11] 229: spec.instance_variable_set :@authors, array[12] 230: spec.instance_variable_set :@description, array[13] 231: spec.instance_variable_set :@homepage, array[14] 232: spec.instance_variable_set :@has_rdoc, array[15] 233: spec.instance_variable_set :@new_platform, array[16] 234: spec.instance_variable_set :@platform, array[16].to_s 235: spec.instance_variable_set :@license, array[17] 236: spec.instance_variable_set :@loaded, false 237: 238: spec 239: end
Specification attributes that are arrays (appendable and so-forth)
# File lib/rubygems/specification.rb, line 154 154: def self.array_attributes 155: @@array_attributes.dup 156: end
# File lib/rubygems/specification.rb, line 126 126: def self.attribute_names 127: @@attributes.dup 128: end
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.
# File lib/rubygems/specification.rb, line 389 389: def self.from_yaml(input) 390: input = normalize_yaml_input input 391: spec = YAML.load input 392: 393: if spec && spec.class == FalseClass then 394: raise Gem::EndOfYAMLException 395: end 396: 397: unless Gem::Specification === spec then 398: raise Gem::Exception, "YAML data doesn't evaluate to gem specification" 399: end 400: 401: unless (spec.instance_variables.include? '@specification_version' or 402: spec.instance_variables.include? :@specification_version) and 403: spec.instance_variable_get :@specification_version 404: spec.instance_variable_set :@specification_version, 405: NONEXISTENT_SPECIFICATION_VERSION 406: end 407: 408: spec 409: end
Loads Ruby format gemspec from file.
# File lib/rubygems/specification.rb, line 414 414: def self.load file 415: return unless file && File.file?(file) 416: 417: file = file.dup.untaint 418: 419: code = if defined? Encoding 420: File.read file, :encoding => "UTF-8" 421: else 422: File.read file 423: end 424: 425: code.untaint 426: 427: begin 428: spec = eval code, binding, file 429: 430: if Gem::Specification === spec 431: spec.loaded_from = file 432: return spec 433: end 434: 435: warn "[#{file}] isn't a Gem::Specification (#{spec.class} instead)." 436: rescue SignalException, SystemExit 437: raise 438: rescue SyntaxError, Exception => e 439: warn "Invalid gemspec in [#{file}]: #{e}" 440: end 441: 442: nil 443: end
Specification constructor. Assigns the default values to the attributes and yields itself for further initialization. Optionally takes name and version.
# File lib/rubygems/specification.rb, line 323 323: def initialize name = nil, version = nil 324: @new_platform = nil 325: @loaded = false 326: @loaded_from = nil 327: @original_platform = nil 328: 329: @@nil_attributes.each do |key| 330: instance_variable_set "@#{key}", nil 331: end 332: 333: @@non_nil_attributes.each do |key| 334: default = default_value(key) 335: value = case default 336: when Time, Numeric, Symbol, true, false, nil then default 337: else default.dup 338: end 339: 340: instance_variable_set "@#{key}", value 341: end 342: 343: # HACK 344: instance_variable_set :@new_platform, Gem::Platform::RUBY 345: 346: self.name = name if name 347: self.version = version if version 348: 349: yield self if block_given? 350: end
Specification attributes that must be non-nil
# File lib/rubygems/specification.rb, line 161 161: def self.non_nil_attributes 162: @@non_nil_attributes.dup 163: end
Make sure the YAML specification is properly formatted with dashes
# File lib/rubygems/specification.rb, line 448 448: def self.normalize_yaml_input(input) 449: result = input.respond_to?(:read) ? input.read : input 450: result = "--- " + result unless result =~ /\A--- / 451: result.gsub(/ !!null \n/, " \n") 452: end
Is name a required attribute?
# File lib/rubygems/specification.rb, line 147 147: def self.required_attribute?(name) 148: @@required_attributes.include? name.to_sym 149: end
Required specification attributes
# File lib/rubygems/specification.rb, line 140 140: def self.required_attributes 141: @@required_attributes.dup 142: end
Dump only crucial instance variables.
# File lib/rubygems/specification.rb, line 171 171: def _dump(limit) 172: Marshal.dump [ 173: @rubygems_version, 174: @specification_version, 175: @name, 176: @version, 177: date, 178: @summary, 179: @required_ruby_version, 180: @required_rubygems_version, 181: @original_platform, 182: @dependencies, 183: @rubyforge_project, 184: @email, 185: @authors, 186: @description, 187: @homepage, 188: true, # has_rdoc 189: @new_platform, 190: @licenses 191: ] 192: end
Returns an array with bindir attached to each executable in the executables list
# File lib/rubygems/specification.rb, line 279 279: def add_bindir(executables) 280: return nil if executables.nil? 281: 282: if @bindir then 283: Array(executables).map { |e| File.join(@bindir, e) } 284: else 285: executables 286: end 287: rescue 288: return nil 289: end
Adds a development dependency named gem with requirements to this Gem. For example:
spec.add_development_dependency 'jabber4r', '> 0.1', '<= 0.5'
Development dependencies aren‘t installed by default and aren‘t activated when a gem is required.
# File lib/rubygems/specification.rb, line 482 482: def add_development_dependency(gem, *requirements) 483: add_dependency_with_type(gem, :development, *requirements) 484: end
Adds a runtime dependency named gem with requirements to this Gem. For example:
spec.add_runtime_dependency 'jabber4r', '> 0.1', '<= 0.5'
# File lib/rubygems/specification.rb, line 492 492: def add_runtime_dependency(gem, *requirements) 493: add_dependency_with_type(gem, :runtime, *requirements) 494: end
A macro to yield cached gem path
# File lib/rubygems/specification.rb, line 595 595: def cache_gem 596: cache_name = File.join(Gem.dir, 'cache', file_name) 597: return File.exist?(cache_name) ? cache_name : nil 598: end
The default value for specification attribute name
# File lib/rubygems/specification.rb, line 133 133: def default_value(name) 134: @@default_value[name] 135: end
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]]
# File lib/rubygems/specification.rb, line 915 915: def dependent_gems 916: out = [] 917: Gem.source_index.each do |name,gem| 918: gem.dependencies.each do |dep| 919: if self.satisfies_requirement?(dep) then 920: sats = [] 921: find_all_satisfiers(dep) do |sat| 922: sats << sat 923: end 924: out << [gem, dep, sats] 925: end 926: end 927: end 928: out 929: end
List of dependencies that are used for development
# File lib/rubygems/specification.rb, line 251 251: def development_dependencies 252: dependencies.select { |d| d.type == :development } 253: end
Creates a duplicate spec without large blobs that aren‘t used at runtime.
# File lib/rubygems/specification.rb, line 642 642: def for_cache 643: spec = dup 644: 645: spec.files = nil 646: spec.test_files = nil 647: 648: spec 649: end
The full path to the gem (install path + full name).
# File lib/rubygems/specification.rb, line 529 529: def full_gem_path 530: path = File.join installation_path, 'gems', full_name 531: return path if File.directory? path 532: File.join installation_path, 'gems', original_name 533: end
Returns the full name (name-version) of this Gem. Platform information is included (name-version-platform) if it is specified and not the default Ruby platform.
# File lib/rubygems/specification.rb, line 506 506: def full_name 507: if platform == Gem::Platform::RUBY or platform.nil? then 508: "#{@name}-#{@version}" 509: else 510: "#{@name}-#{@version}-#{platform}" 511: end 512: end
True if this gem has files in test_files
# File lib/rubygems/specification.rb, line 310 310: def has_unit_tests? 311: not test_files.empty? 312: end
Duplicates array_attributes from other_spec so state isn‘t shared.
# File lib/rubygems/specification.rb, line 355 355: def initialize_copy(other_spec) 356: other_ivars = other_spec.instance_variables 357: other_ivars = other_ivars.map { |ivar| ivar.intern } if # for 1.9 358: String === other_ivars.first 359: 360: self.class.array_attributes.each do |name| 361: name = "@#{name}""@#{name}" 362: next unless other_ivars.include? name 363: 364: begin 365: val = other_spec.instance_variable_get(name) 366: if val then 367: instance_variable_set name, val.dup 368: else 369: warn "WARNING: #{full_name} has an invalid nil value for #{name}" 370: end 371: rescue TypeError 372: e = Gem::FormatException.new \ 373: "#{full_name} has an invalid value for #{name}" 374: 375: e.file_path = loaded_from 376: raise e 377: end 378: end 379: end
The directory that this gem was installed into.
# File lib/rubygems/specification.rb, line 547 547: def installation_path 548: unless @loaded_from then 549: raise Gem::Exception, "spec #{full_name} is not from an installed gem" 550: end 551: 552: File.expand_path File.dirname(File.dirname(@loaded_from)) 553: end
Sets the rubygems_version to the current RubyGems version
# File lib/rubygems/specification.rb, line 457 457: def mark_version 458: @rubygems_version = Gem::VERSION 459: end
Normalize the list of files so that:
# File lib/rubygems/specification.rb, line 900 900: def normalize 901: if defined?(@extra_rdoc_files) and @extra_rdoc_files then 902: @extra_rdoc_files.uniq! 903: @files ||= [] 904: @files.concat(@extra_rdoc_files) 905: end 906: @files.uniq! if @files 907: end
List of dependencies that will automatically be activated at runtime.
# File lib/rubygems/specification.rb, line 244 244: def runtime_dependencies 245: dependencies.select { |d| d.type == :runtime } 246: end
Checks if this specification meets the requirement of dependency.
# File lib/rubygems/specification.rb, line 558 558: def satisfies_requirement?(dependency) 559: return @name == dependency.name && 560: dependency.requirement.satisfied_by?(@version) 561: end
Returns an object you can use to sort specifications in sort_by.
# File lib/rubygems/specification.rb, line 566 566: def sort_obj 567: [@name, @version, @new_platform == Gem::Platform::RUBY ? -1 : 1] 568: end
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.
# File lib/rubygems/specification.rb, line 681 681: def to_ruby 682: mark_version 683: result = [] 684: result << "# -*- encoding: utf-8 -*-" 685: result << nil 686: result << "Gem::Specification.new do |s|" 687: 688: result << " s.name = #{ruby_code name}" 689: result << " s.version = #{ruby_code version}" 690: unless platform.nil? or platform == Gem::Platform::RUBY then 691: result << " s.platform = #{ruby_code original_platform}" 692: end 693: result << "" 694: result << " s.required_rubygems_version = #{ruby_code required_rubygems_version} if s.respond_to? :required_rubygems_version=" 695: 696: handled = [ 697: :dependencies, 698: :name, 699: :platform, 700: :required_rubygems_version, 701: :specification_version, 702: :version, 703: :has_rdoc, 704: ] 705: 706: @@attributes.each do |attr_name| 707: next if handled.include? attr_name 708: current_value = self.send(attr_name) 709: if current_value != default_value(attr_name) or 710: self.class.required_attribute? attr_name then 711: result << " s.#{attr_name} = #{ruby_code current_value}" 712: end 713: end 714: 715: result << nil 716: result << " if s.respond_to? :specification_version then" 717: result << " s.specification_version = #{specification_version}" 718: result << nil 719: 720: result << " if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then" 721: 722: dependencies.each do |dep| 723: req = dep.requirements_list.inspect 724: dep.instance_variable_set :@type, :runtime if dep.type.nil? # HACK 725: result << " s.add_#{dep.type}_dependency(%q<#{dep.name}>, #{req})" 726: end 727: 728: result << " else" 729: 730: dependencies.each do |dep| 731: version_reqs_param = dep.requirements_list.inspect 732: result << " s.add_dependency(%q<#{dep.name}>, #{version_reqs_param})" 733: end 734: 735: result << ' end' 736: 737: result << " else" 738: dependencies.each do |dep| 739: version_reqs_param = dep.requirements_list.inspect 740: result << " s.add_dependency(%q<#{dep.name}>, #{version_reqs_param})" 741: end 742: result << " end" 743: 744: result << "end" 745: result << nil 746: 747: result.join "\n" 748: end
# File lib/rubygems/specification.rb, line 750 750: def to_ruby_for_cache 751: for_cache.to_ruby 752: end
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..
# File lib/rubygems/specification.rb, line 761 761: def validate packaging = true 762: require 'rubygems/user_interaction' 763: extend Gem::UserInteraction 764: normalize 765: 766: nil_attributes = self.class.non_nil_attributes.find_all do |name| 767: instance_variable_get("@#{name}").nil? 768: end 769: 770: unless nil_attributes.empty? then 771: raise Gem::InvalidSpecificationException, 772: "#{nil_attributes.join ', '} must not be nil" 773: end 774: 775: if packaging and rubygems_version != Gem::VERSION then 776: raise Gem::InvalidSpecificationException, 777: "expected RubyGems version #{Gem::VERSION}, was #{rubygems_version}" 778: end 779: 780: @@required_attributes.each do |symbol| 781: unless self.send symbol then 782: raise Gem::InvalidSpecificationException, 783: "missing value for attribute #{symbol}" 784: end 785: end 786: 787: unless String === name then 788: raise Gem::InvalidSpecificationException, 789: "invalid value for attribute name: \"#{name.inspect}\"" 790: end 791: 792: if require_paths.empty? then 793: raise Gem::InvalidSpecificationException, 794: 'specification must have at least one require_path' 795: end 796: 797: @files.delete_if do |file| File.directory? file end 798: @test_files.delete_if do |file| File.directory? file end 799: @executables.delete_if do |file| 800: File.directory? File.join(bindir, file) 801: end 802: @extra_rdoc_files.delete_if do |file| File.directory? file end 803: @extensions.delete_if do |file| File.directory? file end 804: 805: non_files = files.select do |file| 806: !File.file? file 807: end 808: 809: unless not packaging or non_files.empty? then 810: non_files = non_files.map { |file| file.inspect } 811: raise Gem::InvalidSpecificationException, 812: "[#{non_files.join ", "}] are not files" 813: end 814: 815: unless specification_version.is_a?(Fixnum) 816: raise Gem::InvalidSpecificationException, 817: 'specification_version must be a Fixnum (did you mean version?)' 818: end 819: 820: case platform 821: when Gem::Platform, Gem::Platform::RUBY then # ok 822: else 823: raise Gem::InvalidSpecificationException, 824: "invalid platform #{platform.inspect}, see Gem::Platform" 825: end 826: 827: self.class.array_attributes.each do |symbol| 828: val = self.send symbol 829: klass = symbol == :dependencies ? Gem::Dependency : String 830: 831: unless Array === val and val.all? { |x| klass === x } then 832: raise(Gem::InvalidSpecificationException, 833: "#{symbol} must be an Array of #{klass} instances") 834: end 835: end 836: 837: licenses.each { |license| 838: if license.length > 64 839: raise Gem::InvalidSpecificationException, 840: "each license must be 64 characters or less" 841: end 842: } 843: 844: # reject lazy developers: 845: 846: lazy = '"FIxxxXME" or "TOxxxDO"'.gsub(/xxx/, '') 847: 848: unless authors.grep(/FI XME|TO DO/x).empty? then 849: raise Gem::InvalidSpecificationException, "#{lazy} is not an author" 850: end 851: 852: unless Array(email).grep(/FI XME|TO DO/x).empty? then 853: raise Gem::InvalidSpecificationException, "#{lazy} is not an email" 854: end 855: 856: if description =~ /FI XME|TO DO/x then 857: raise Gem::InvalidSpecificationException, "#{lazy} is not a description" 858: end 859: 860: if summary =~ /FI XME|TO DO/x then 861: raise Gem::InvalidSpecificationException, "#{lazy} is not a summary" 862: end 863: 864: if homepage and not homepage.empty? and 865: homepage !~ /\A[a-z][a-z\d+.-]*:/i then 866: raise Gem::InvalidSpecificationException, 867: "\"#{homepage}\" is not a URI" 868: end 869: 870: # Warnings 871: 872: %w[author description email homepage summary].each do |attribute| 873: value = self.send attribute 874: alert_warning "no #{attribute} specified" if value.nil? or value.empty? 875: end 876: 877: if description == summary then 878: alert_warning 'description and summary are identical' 879: end 880: 881: # TODO: raise at some given date 882: alert_warning "deprecated autorequire specified" if autorequire 883: 884: executables.each do |executable| 885: executable_path = File.join bindir, executable 886: shebang = File.read(executable_path, 2) == '#!' 887: 888: alert_warning "#{executable_path} is missing #! line" unless shebang 889: end 890: 891: true 892: end
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. As of RubyGems 1.3.2 newlines are no longer stripped. |
version | [R] | This gem‘s version |
autorequire | [RW] | Autorequire was used by old RubyGems to automatically require a file. It no longer is supported. |
bindir | [RW] | The path in the gem for executable scripts |
cert_chain | [RW] | The certificate chain used to sign this gem. See Gem::Security for details. |
default_executable | [W] | The default executable for this gem. |
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 |
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. |
The list of author names who wrote 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.
# File lib/rubygems/specification.rb, line 1141 1141: def authors 1142: @authors ||= [] 1143: end
# File lib/rubygems/specification.rb, line 1145 1145: def authors=(value) 1146: @authors = Array(value) 1147: end
A list of Gem::Dependency objects this gem depends on.
Use add_dependency or add_development_dependency to add dependencies to a gem.
# File lib/rubygems/specification.rb, line 1258 1258: def dependencies 1259: @dependencies ||= [] 1260: end
Executables included in the gem.
# File lib/rubygems/specification.rb, line 1217 1217: def executables 1218: @executables ||= [] 1219: end
# File lib/rubygems/specification.rb, line 1221 1221: def executables=(value) 1222: # TODO: warn about setting instead of pushing 1223: @executables = Array(value) 1224: end
Extensions to build when installing the gem. See Gem::Installer#build_extensions for valid values.
# File lib/rubygems/specification.rb, line 1230 1230: def extensions 1231: @extensions ||= [] 1232: end
# File lib/rubygems/specification.rb, line 1234 1234: def extensions=(value) 1235: # TODO: warn about setting instead of pushing 1236: @extensions = Array(value) 1237: end
# File lib/rubygems/specification.rb, line 1209 1209: def extra_rdoc_files=(value) 1210: # TODO: warn about setting instead of pushing 1211: @extra_rdoc_files = Array(value) 1212: end
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.
# File lib/rubygems/specification.rb, line 1170 1170: def files 1171: @files ||= [] 1172: end
# File lib/rubygems/specification.rb, line 1174 1174: def files=(value) 1175: @files = Array(value) 1176: end
# File lib/rubygems/specification.rb, line 1157 1157: def licenses=(value) 1158: @licenses = Array(value) 1159: end
An ARGV style array of options to RDoc
# File lib/rubygems/specification.rb, line 1193 1193: def rdoc_options 1194: @rdoc_options ||= [] 1195: end
# File lib/rubygems/specification.rb, line 1197 1197: def rdoc_options=(value) 1198: # TODO: warn about setting instead of pushing 1199: @rdoc_options = Array(value) 1200: end
An array or things required by this gem. Not used by anything presently.
# File lib/rubygems/specification.rb, line 1243 1243: def requirements 1244: @requirements ||= [] 1245: end
# File lib/rubygems/specification.rb, line 1247 1247: def requirements=(value) 1248: # TODO: warn about setting instead of pushing 1249: @requirements = Array(value) 1250: end
# File lib/rubygems/specification.rb, line 1506 1506: def conflicts 1507: conflicts = {} 1508: Gem.loaded_specs.values.each do |spec| 1509: bad = self.runtime_dependencies.find_all { |dep| 1510: spec.name == dep.name and not spec.satisfies_requirement? dep 1511: } 1512: 1513: conflicts[spec] = bad unless bad.empty? 1514: end 1515: conflicts 1516: end
The date this gem was created
Do not set this, it is set automatically when the gem is packaged.
# File lib/rubygems/specification.rb, line 1424 1424: def date= date 1425: # We want to end up with a Time object with one-day resolution. 1426: # This is the cleanest, most-readable, faster-than-using-Date 1427: # way to do it. 1428: @date = case date 1429: when String then 1430: if /\A(\d{4})-(\d{2})-(\d{2})\Z/ =~ date then 1431: Time.utc($1.to_i, $2.to_i, $3.to_i) 1432: else 1433: raise(Gem::InvalidSpecificationException, 1434: "invalid date format in specification: #{date.inspect}") 1435: end 1436: when Time, Date then 1437: Time.utc(date.year, date.month, date.day) 1438: else 1439: TODAY 1440: end 1441: end
The default executable for this gem.
# File lib/rubygems/specification.rb, line 1468 1468: def default_executable 1469: if defined?(@default_executable) and @default_executable 1470: result = @default_executable 1471: elsif @executables and @executables.size == 1 1472: result = Array(@executables).first 1473: else 1474: result = nil 1475: end 1476: result 1477: end
# File lib/rubygems/specification.rb, line 1530 1530: def dependent_specs 1531: runtime_dependencies.map { |dep| Gem.source_index.search dep, true }.flatten 1532: end
A long description of this gem
# File lib/rubygems/specification.rb, line 1461 1461: def description= str 1462: @description = str.to_s 1463: end
Singular accessor for executables
# File lib/rubygems/specification.rb, line 1267 1267: def executable 1268: val = executables and val.first 1269: end
Singular accessor for executables
# File lib/rubygems/specification.rb, line 1274 1274: def executable=o 1275: self.executables = [o] 1276: end
# File lib/rubygems/specification.rb, line 1496 1496: def files 1497: # DO NOT CHANGE TO ||= ! This is not a normal accessor. (yes, it sucks) 1498: @files = [@files, 1499: @test_files, 1500: add_bindir(@executables), 1501: @extra_rdoc_files, 1502: @extensions, 1503: ].flatten.uniq.compact 1504: end
Deprecated and ignored, defaults to true.
Formerly used to indicate this gem was RDoc-capable.
# File lib/rubygems/specification.rb, line 1339 1339: def has_rdoc 1340: true 1341: end
Deprecated and ignored.
Formerly used to indicate this gem was RDoc-capable.
# File lib/rubygems/specification.rb, line 1348 1348: def has_rdoc= v 1349: @has_rdoc = true 1350: end
The platform this gem runs on. See Gem::Platform for details.
# File lib/rubygems/specification.rb, line 1363 1363: def platform 1364: @new_platform 1365: end
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.
# File lib/rubygems/specification.rb, line 1373 1373: def platform= platform 1374: if @original_platform.nil? or 1375: @original_platform == Gem::Platform::RUBY then 1376: @original_platform = platform 1377: end 1378: 1379: case platform 1380: when Gem::Platform::CURRENT then 1381: @new_platform = Gem::Platform.local 1382: @original_platform = @new_platform.to_s 1383: 1384: when Gem::Platform then 1385: @new_platform = platform 1386: 1387: # legacy constants 1388: when nil, Gem::Platform::RUBY then 1389: @new_platform = Gem::Platform::RUBY 1390: when 'mswin32' then # was Gem::Platform::WIN32 1391: @new_platform = Gem::Platform.new 'x86-mswin32' 1392: when 'i586-linux' then # was Gem::Platform::LINUX_586 1393: @new_platform = Gem::Platform.new 'x86-linux' 1394: when 'powerpc-darwin' then # was Gem::Platform::DARWIN 1395: @new_platform = Gem::Platform.new 'ppc-darwin' 1396: else 1397: @new_platform = Gem::Platform.new platform 1398: end 1399: 1400: @platform = @new_platform.to_s 1401: 1402: @new_platform 1403: end
Singular accessor for require_paths
# File lib/rubygems/specification.rb, line 1309 1309: def require_path 1310: val = require_paths and val.first 1311: end
Singular accessor for require_paths
# File lib/rubygems/specification.rb, line 1316 1316: def require_path=o 1317: self.require_paths = [o] 1318: end
The version of ruby required by this gem
# File lib/rubygems/specification.rb, line 1408 1408: def required_ruby_version= value 1409: @required_ruby_version = Gem::Requirement.create(value) 1410: end
The RubyGems version required by this gem
# File lib/rubygems/specification.rb, line 1415 1415: def required_rubygems_version= value 1416: @required_rubygems_version = Gem::Requirement.create(value) 1417: end
A short summary of this gem‘s description.
# File lib/rubygems/specification.rb, line 1453 1453: def summary= str 1454: @summary = str.to_s.strip. 1455: gsub(/(\w-)\n[ \t]*(\w)/, '\1\2').gsub(/\n[ \t]*/, " ") # so. weird. 1456: end
Singular accessor for test_files
# File lib/rubygems/specification.rb, line 1323 1323: def test_file 1324: val = test_files and val.first 1325: end
Singular accessor for test_files
# File lib/rubygems/specification.rb, line 1330 1330: def test_file=o 1331: self.test_files = [o] 1332: end
# File lib/rubygems/specification.rb, line 1480 1480: def test_files 1481: # Handle the possibility that we have @test_suite_file but not 1482: # @test_files. This will happen when an old gem is loaded via 1483: # YAML. 1484: if defined? @test_suite_file then 1485: @test_files = [@test_suite_file].flatten 1486: @test_suite_file = nil 1487: end 1488: if defined?(@test_files) and @test_files then 1489: @test_files 1490: else 1491: @test_files = [] 1492: end 1493: end
# File lib/rubygems/specification.rb, line 1518 1518: def traverse trail = [], &b 1519: trail = trail + [self] 1520: runtime_dependencies.each do |dep| 1521: dep_specs = Gem.source_index.search dep, true 1522: dep_specs.each do |dep_spec| 1523: b[self, dep, dep_spec, trail + [dep_spec]] 1524: dep_spec.traverse(trail, &b) unless 1525: trail.map(&:name).include? dep_spec.name 1526: end 1527: end 1528: end