lib/pupil/keygen/base.rb in pupil-0.3.3 vs lib/pupil/keygen/base.rb in pupil-0.4

- old
+ new

@@ -28,41 +28,36 @@ @access_token = access_token.token @access_token_secret = access_token.secret return {:access_token => access_token.token, :access_token_secret => access_token.secret} end - def pupilkey + def pupil_key raise MissingRequiredTokens, "Pupil::Keygen#pupilkey require consumer_key, consumer_secret, access_token and access_token_secret" unless @consumer_key || @consumer_secret || @access_token || @access_token_secret return { :consumer_key => @consumer_key, :consumer_secret => @consumer_secret, :access_token => @access_token, :access_token_secret => @access_token_secret } end def interactive - print "Enter OAuth Consumer Key: " unless @consumer_key - @consumer_key = gets.chomp.strip unless @consumer_key - print "Enter OAuth Consumer Secret: " unless @consumer_secret - @consumer_secret = gets.chomp.strip unless @consumer_secret + @consumer_key = Readline.readline("Enter OAuth Consumer Key: ", true) unless @consumer_key + print unless @consumer_secret + @consumer_secret = Readline.readline("Enter OAuth Consumer Secret: ", true) unless @consumer_secret consumer = OAuth::Consumer.new(@consumer_key, @consumer_secret, :site => 'http://twitter.com') request_token = consumer.get_request_token puts "Access to this URL and approve: #{request_token.authorize_url}" + + oauth_verifier = Readline.readline("Enter OAuth Verifier: ", true) - print "Enter OAuth Verifier: " - oauth_verifier = gets.chomp.strip - access_token = request_token.get_access_token(:oauth_verifier => oauth_verifier) @access_token = access_token.token @access_token_secret = access_token.secret - puts "Process complete!" - puts "Access token: #{access_token.token}" - puts "Access token secret: #{access_token.secret}" - return {:consumer_key => @consumer_key, :consumer_secret => @consumer_secret, :access_token => access_token.token, :access_token_secret => access_token.secret} + return {:consumer_key => @consumer_key, :consumer_secret => @consumer_secret, :access_token => access_token.token, :access_token_secret => access_token.secret, :screen_name => access_token.params[:screen_name]} end end end \ No newline at end of file