Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
class method
Gem::Security.write
write(pemmable, path, permissions = 0o600, passphrase = nil, cipher = KEY_CIPHER)
lib/rubygems/security.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.3.0/lib/rubygems/security.rb, line 592
def self.write(pemmable, path, permissions = 0o600, passphrase = nil, cipher = KEY_CIPHER)
path = File.expand_path path
File.open path, "wb", permissions do |io|
if passphrase && cipher
io.write pemmable.to_pem cipher, passphrase
else
io.write pemmable.to_pem
end
end
path
end
Writes pemmable, which must respond to to_pem to path with the given permissions. If passed cipher and passphrase those arguments will be passed to to_pem.