Module: Gist::AuthTokenFile

Defined in:
lib/gist.rb

Overview

helper module for authentication token actions

Class Method Summary collapse

Class Method Details

.filenameObject



51
52
53
54
55
56
57
# File 'lib/gist.rb', line 51

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



59
60
61
# File 'lib/gist.rb', line 59

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

.write(token) ⇒ Object



63
64
65
66
67
# File 'lib/gist.rb', line 63

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