15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/twitter/config.rb', line 15
def self.for_user(username, options = {})
path = options[:path] || "#{ENV['HOME']}/.trc"
config_data = YAML.load_file path
user_config = {}
if config_data['profiles'].nil?
user_config = config_data[username]
else
user_config = config_data['profiles'][username].values.first
end
raise "no config found for #{username} in file #{path}" if user_config.nil?
return {
:consumer_key => user_config['consumer_key'],
:consumer_secret => user_config['consumer_secret'],
:access_token => user_config['token'] || user_config['access_token'],
:access_token_secret => user_config['secret'] || user_config['access_token_secret']
}
end
|