Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Gem::GemcutterUtilities#api_key
api_key
lib/rubygems/gemcutter_utilities.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/rubygems/gemcutter_utilities.rb, line 46
def api_key
if ENV["GEM_HOST_API_KEY"]
ENV["GEM_HOST_API_KEY"]
elsif options[:key]
verify_api_key options[:key]
elsif credential_store_key = Gem.configuration.credential_store_api_key_for(host)
credential_store_key
elsif Gem.configuration.api_keys.key?(host)
Gem.configuration.api_keys[host]
else
key = Gem.configuration.rubygems_api_key
# Once the store has refused to answer, this last resort would hand the
# RubyGems.org key to a host that has one of its own, or come away with
# nothing and let the caller ask for a password.
if !@recognizing_session && Gem.configuration.credential_store_read_failed_for?(host) && (key.nil? || !default_host?)
alert_error "The credential store could not be read, so no API key for #{host} could be found. " \
"Make the store readable and run the command again."
terminate_interaction ERROR_CODE
end
key
end
end
The API key from the command options or from the user’s configuration.
See also
#add_otp_option
#api_key_forbidden?
#add_key_option
#default_host?
also in
4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0