Class: Factorix::APICredential
- Inherits:
-
Data
- Object
- Data
- Factorix::APICredential
- Defined in:
- lib/factorix/api_credential.rb,
lib/factorix/api_credential.rb
Overview
API credentials for Factorio MOD Portal management
Instance Attribute Summary collapse
-
#api_key ⇒ String
readonly
API key for Factorio MOD Portal.
Class Method Summary collapse
-
.load ⇒ APICredential
Load API credentials from environment variables.
Instance Method Summary collapse
-
#inspect ⇒ String
(also: #to_s)
String representation with masked API key.
- #pretty_print(pp) ⇒ void
Instance Attribute Details
#api_key ⇒ String (readonly)
Returns API key for Factorio MOD Portal.
13 14 15 |
# File 'lib/factorix/api_credential.rb', line 13 def api_key @api_key end |
Class Method Details
.load ⇒ APICredential
Load API credentials from environment variables
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/factorix/api_credential.rb', line 24 def self.load logger = Container["logger"] logger.debug "Loading API credentials from environment" api_key = ENV.fetch(ENV_API_KEY, nil) if api_key.nil? logger.error("Failed to load API credentials", reason: "#{ENV_API_KEY} not set") raise CredentialError, "#{ENV_API_KEY} environment variable is not set" end if api_key.empty? logger.error("Failed to load API credentials", reason: "#{ENV_API_KEY} is empty") raise CredentialError, "#{ENV_API_KEY} environment variable is empty" end logger.info("API credentials loaded successfully") new(api_key:) end |
Instance Method Details
#inspect ⇒ String Also known as: to_s
Returns string representation with masked API key.
46 |
# File 'lib/factorix/api_credential.rb', line 46 def inspect = %[#<#{self.class} api_key="*****">] |
#pretty_print(pp) ⇒ void
This method returns an undefined value.
52 |
# File 'lib/factorix/api_credential.rb', line 52 def pretty_print(pp) = pp.text(inspect) |