Module: Gist::AuthTokenFile

Defined in:
lib/gist.rb

Overview

helper module for authentication token actions

Class Method Summary collapse

Class Method Details

.filenameObject



49
50
51
52
53
54
55
# File 'lib/gist.rb', line 49

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



57
58
59
# File 'lib/gist.rb', line 57

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

.write(token) ⇒ Object



61
62
63
64
65
# File 'lib/gist.rb', line 61

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