Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Gem::ConfigFile#set_api_key
set_api_key(host, api_key)
lib/rubygems/config_file.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.4.1/lib/rubygems/config_file.rb, line 339
def set_api_key(host, api_key)
check_credentials_permissions
config = load_file(credentials_path).merge(host => api_key)
dirname = File.dirname credentials_path
require "fileutils"
FileUtils.mkdir_p(dirname)
permissions = 0o600 & (~File.umask)
File.open(credentials_path, "w", permissions) do |f|
f.write self.class.dump_with_rubygems_yaml(config)
end
load_api_keys # reload
end
Set a specific host’s API key to api_key
See also
#rubygems_api_key=
#set_config_file_name
#rubygems_api_key
#state_file_name
also in
4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0