Sha256: 97c885d2ee491872586d6b34f9cf01f707ddd9f69612403d953addc9bb0c4132
Contents?: true
Size: 923 Bytes
Versions: 1
Compression:
Stored size: 923 Bytes
Contents
require "methadone" require "fileutils" module Howami class Configuration include Methadone::CLILogging XDG_CONFIG_HOME = ENV['XDG_CONFIG_HOME'] || File.join(ENV['HOME'], '.config') CREDENTIALS_STORE = File.join( XDG_CONFIG_HOME, "howami", "credentials.yml") def self.has_valid_credentials? self.has_stored_credentials? end def self.store_credentials(user_token, user_secret) #create proper XDG directory if doesn't exist FileUtils.mkdir_p( File.dirname(CREDENTIALS_STORE) ) #store File.open(CREDENTIALS_STORE, 'w') do |f| f.puts({ :user_token => user_token, :user_secret => user_secret }.to_yaml) end end def self.get_credentials return nil if not self.has_stored_credentials? YAML.load_file(CREDENTIALS_STORE) end protected def self.has_stored_credentials? File.exist? CREDENTIALS_STORE end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
howami-0.0.2 | lib/howami/configuration.rb |