Class: Nauvisian::Credential
- Inherits:
-
Object
- Object
- Nauvisian::Credential
- Defined in:
- lib/nauvisian/credential.rb
Class Method Summary collapse
- .from_env ⇒ Object
- .from_player_data_file(player_data_file_path: Nauvisian.platform.user_data_directory / "player-data.json") ⇒ Object
Class Method Details
.from_env ⇒ Object
13 14 15 16 |
# File 'lib/nauvisian/credential.rb', line 13 def self.from_env # NOTE: values of ENV are already frozen self[username: ENV.fetch("FACTORIO_SERVICE_USERNAME"), token: ENV.fetch("FACTORIO_SERVICE_TOKEN")] end |
.from_player_data_file(player_data_file_path: Nauvisian.platform.user_data_directory / "player-data.json") ⇒ Object
18 19 20 21 |
# File 'lib/nauvisian/credential.rb', line 18 def self.from_player_data_file(player_data_file_path: Nauvisian.platform.user_data_directory / "player-data.json") data = JSON.load_file(player_data_file_path) self[username: data["service-username"].freeze, token: data["service-token"].freeze] end |