Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Gem::Package#build_content_addressable_file
build_content_addressable_file(skip_validation = false, strict_validation = false)
lib/rubygems/package.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/rubygems/package.rb, line 403
def build_content_addressable_file(skip_validation = false, strict_validation = false)
Gem::ContentAddress.eligible!(@spec)
ruby_abi = Gem::ContentAddress.ruby_abi_for(@spec.required_ruby_version)
@spec.required_rubygems_version = normalized_required_rubygems_version(ruby_abi)
build skip_validation, strict_validation
bytes = @gem.with_read_io(&:read)
gem_file = "#{@spec.name}-#{@spec.version}-#{Gem::ContentAddress.address_for(bytes)}.gem"
File.binwrite(gem_file, bytes)
say " File: #{gem_file}"
say " Platform: #{@spec.platform}"
say " Ruby ABI: #{ruby_abi}"
gem_file
end
Builds this package and writes it to a content-addressable file name derived from the SHA-256 digest of the gem contents, for example “example-1.0-01234567.gem”. Returns the written file name.
The spec is validated for content addressing. Its required_ruby_version determines the Ruby ABI, while its required_rubygems_version is constrained before building.