class Shellify::Config
Constants
- CONFIG_DIR
- CONFIG_FILE
- SPOTIFY_AUTHORIZATION_SCOPES
Attributes
client_id[RW]
client_secret[RW]
config_dir[RW]
Public Class Methods
new()
click to toggle source
# File lib/shellify/config.rb, line 21 def initialize @config_dir = CONFIG_DIR @config_file = CONFIG_FILE load_config RSpotify.authenticate(@client_id, @client_secret) if configured? end
Public Instance Methods
configured?()
click to toggle source
# File lib/shellify/config.rb, line 28 def configured? !@client_id.nil? && !@client_secret.nil? end
save!()
click to toggle source
# File lib/shellify/config.rb, line 32 def save! File.open(CONFIG_FILE, 'w') do |file| file.write(JSON.pretty_generate({client_id: @client_id, client_secret: @client_secret})) end end
Private Instance Methods
load_config()
click to toggle source
# File lib/shellify/config.rb, line 40 def load_config return unless File.exists?(CONFIG_FILE) JSON.parse(File.read(CONFIG_FILE)).each_pair { |k,v| instance_variable_set("@#{k}", v) } end