Class: Factorix::ServiceCredential
- Inherits:
-
Data
- Object
- Data
- Factorix::ServiceCredential
- Defined in:
- lib/factorix/service_credential.rb,
lib/factorix/service_credential.rb
Overview
Service credentials for Factorio MOD downloads
Instance Attribute Summary collapse
-
#token ⇒ String
readonly
Factorio service token.
-
#username ⇒ String
readonly
Factorio service username.
Class Method Summary collapse
-
.load ⇒ ServiceCredential
Load service credentials with automatic source detection.
Instance Method Summary collapse
-
#inspect ⇒ String
(also: #to_s)
String representation with masked credentials.
- #pretty_print(pp) ⇒ void
Instance Attribute Details
#token ⇒ String (readonly)
Returns Factorio service token.
12 13 14 |
# File 'lib/factorix/service_credential.rb', line 12 def token @token end |
#username ⇒ String (readonly)
Returns Factorio service username.
12 13 14 |
# File 'lib/factorix/service_credential.rb', line 12 def username @username end |
Class Method Details
.load ⇒ ServiceCredential
Load service credentials with automatic source detection
Tries environment variables first, falls back to player-data.json. Raises an error if only one environment variable is set (partial configuration).
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/factorix/service_credential.rb', line 33 def self.load username_env = ENV.fetch(ENV_USERNAME, nil) token_env = ENV.fetch(ENV_TOKEN, nil) if username_env && token_env from_env elsif username_env || token_env raise CredentialError, "Both #{ENV_USERNAME} and #{ENV_TOKEN} must be set (or neither)" else runtime = Container[:runtime] from_player_data(runtime:) end end |
Instance Method Details
#inspect ⇒ String Also known as: to_s
Returns string representation with masked credentials.
119 |
# File 'lib/factorix/service_credential.rb', line 119 def inspect = %[#<#{self.class} username="*****" token="*****">] |
#pretty_print(pp) ⇒ void
This method returns an undefined value.
125 |
# File 'lib/factorix/service_credential.rb', line 125 def pretty_print(pp) = pp.text(inspect) |