Module: Gist::AuthTokenFile

Defined in:
lib/egist.rb

Overview

helper module for authentication token actions

Class Method Summary collapse

Class Method Details

.filenameObject



45
46
47
48
49
50
51
# File 'lib/egist.rb', line 45

def self.filename
  if ENV.key?(URL_ENV_NAME)
    File.expand_path "~/.gist.#{ENV[URL_ENV_NAME].gsub(/:/, '.').gsub(/[^a-z0-9.]/, '')}"
  else
    File.expand_path "~/.gist"
  end
end

.readObject



53
54
55
# File 'lib/egist.rb', line 53

def self.read
  File.read(filename).chomp
end

.write(token) ⇒ Object



57
58
59
60
61
# File 'lib/egist.rb', line 57

def self.write(token)
  File.open(filename, 'w', 0600) do |f|
    f.write token
  end
end