Sha256: 6dcb093523a3914e335f5bddb56c426dc783fa5b7a2aba5334c99098a24d0ad7
Contents?: true
Size: 924 Bytes
Versions: 4
Compression:
Stored size: 924 Bytes
Contents
# frozen_string_literal: true module SdrClient class RedesignedClient class CLI < Thor # The stored credentials class Credentials # @param [String] a json string that contains a field 'token' def self.write(body) token = JSON.parse(body).fetch('token') FileUtils.mkdir_p(credentials_path, mode: 0o700) File.atomic_write(credentials_file) { |file| file.write(token) } File.chmod(0o600, credentials_file) end def self.read return unless ::File.exist?(credentials_file) creds = File.read(credentials_file, chomp: true) return if creds.nil? creds end def self.credentials_path @credentials_path ||= File.join(Dir.home, '.sdr') end def self.credentials_file File.join(credentials_path, 'credentials') end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems