Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
Gem::Package.build
build(spec, skip_validation = false, strict_validation = false, file_name = nil, content_addressable: false)
lib/rubygems/package.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/rubygems/package.rb, line 161
def self.build(spec, skip_validation = false, strict_validation = false, file_name = nil, content_addressable: false)
if content_addressable && file_name
raise ArgumentError, "Cannot specify an output file name for a content-addressable gem as these gems must use the generated file name."
end
if content_addressable
require "digest"
require "stringio"
io = StringIO.new
io.set_encoding(Encoding::BINARY)
package = new io
package.spec = spec.dup
gem_file = package.build_content_addressable_file skip_validation, strict_validation
spec.required_rubygems_version = package.spec.required_rubygems_version
else
gem_file = file_name || spec.file_name
package = new gem_file
package.spec = spec
package.build skip_validation, strict_validation
end
gem_file
end
Builds the gem described by spec and returns the built file name.
When content_addressable is true, builds a gem named by the SHA-256 digest of its contents. The spec must declare a non-Ruby platform and a required_ruby_version identifying a single Ruby ABI. Its required_rubygems_version is constrained to at least MINIMUM_RUBYGEMS_VERSION. Content-addressable builds are incompatible with file_name.