Class: Nauvisian::Credential

Inherits:
Object
  • Object
show all
Defined in:
lib/nauvisian/credential.rb

Class Method Summary collapse

Class Method Details

.from_envObject



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