lib/twiauth/oauth.rb in twiauth-0.0.2 vs lib/twiauth/oauth.rb in twiauth-0.1.0

- old
+ new

@@ -6,14 +6,16 @@ :request_token_path => '/oauth/request_token', :access_token_path => '/oauth/access_token', :authorize_path => '/oauth/authorize' } - ACCESS_TOKEN = 'access_token.yml' + # key for access token + ACCESS_TOKEN = 'ACCESS_TOKEN' public def initialize(key, secret) + @store = TwiAuth::Store.new @oauth_consumer = ::OAuth::Consumer.new(key, secret, TWITTER_OAUTH_SPEC) get_access_token end def get(path) @@ -23,13 +25,11 @@ def post(path, body = nil) @access_token.post(path, body) end def drop_access_token - if ::File.exists?(ACCESS_TOKEN) - ::File.delete(ACCESS_TOKEN) - end + @store.delete(ACCESS_TOKEN) end private def get_request_token @oauth_consumer.get_request_token @@ -54,18 +54,14 @@ @access_token = request_token.get_access_token(:oauth_verifier => pin) persist_access_token end def pull_access_token - if ::File.exists?(ACCESS_TOKEN) - @access_token = ::YAML.load_file(ACCESS_TOKEN) - end + @access_token = @store.get(ACCESS_TOKEN) end def persist_access_token - ::File.open(ACCESS_TOKEN, 'w') do |out| - YAML.dump(@access_token, out) - end + @store.put(ACCESS_TOKEN,@access_token) end end end \ No newline at end of file