class Awesomekit::Authenticator
Constants
- CONFIG_FILE
Public Class Methods
api_token()
click to toggle source
PUBLIC: Return the current saved api_token
If no token exists, prompt user for token
# File lib/awesomekit/authenticator.rb, line 7 def self.api_token if File.exist?(config) File.open(config, 'r').gets else prompt_user_for_token end end
clear_api_token()
click to toggle source
PUBLIC: Delete any existing api_token
config file
# File lib/awesomekit/authenticator.rb, line 16 def self.clear_api_token File.unlink(config) if File.exist?(config) end
Private Class Methods
config()
click to toggle source
# File lib/awesomekit/authenticator.rb, line 35 def self.config File.join(Dir.home, CONFIG_FILE) end
prompt_user_for_token()
click to toggle source
# File lib/awesomekit/authenticator.rb, line 22 def self.prompt_user_for_token ap('Enter your Adobe Typekit API token: ', color: { string: :yellow }) api_token = STDIN.gets.chomp save_token_to_config(api_token) api_token end
save_token_to_config(api_token)
click to toggle source
# File lib/awesomekit/authenticator.rb, line 29 def self.save_token_to_config(api_token) File.open(config, 'w') do |file| file.write(api_token) end end