Class: TheTwittHit::Config
- Inherits:
-
Object
- Object
- TheTwittHit::Config
- Defined in:
- lib/thetwitthit/config.rb
Constant Summary collapse
- APP_SUPPORT =
File.join(ENV['HOME'], "Library", "Application Support", "The Hit List")
- CONFIG_FILE =
File.join(APP_SUPPORT, 'thetwitthit.yml')
- CONSUMER_KEY =
'IvgtcoFEQaVcvckEjoQQ9w'
- CONSUMER_SECRET =
'mS7iOi5QvLqC4oMupeO1kbVXyngyDa5Jq80qVS9KI8Q'
Instance Method Summary collapse
- #auth(force_auth = true, force_build = false) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #save ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
8 9 10 |
# File 'lib/thetwitthit/config.rb', line 8 def initialize @config = load() end |
Instance Method Details
#auth(force_auth = true, force_build = false) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/thetwitthit/config.rb', line 33 def auth(force_auth = true, force_build = false) if @auth.nil? || force_build @auth = Twitter::OAuth.new(CONSUMER_KEY,CONSUMER_SECRET) if @config[:access_token] @auth.(@config[:access_token], @config[:access_secret]) elsif force_auth raise "Not Authorized" end end @auth end |
#save ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/thetwitthit/config.rb', line 25 def save File.open(CONFIG_FILE, 'w') do |f| YAML::dump(@config, f) end true end |