<commit_before>= Ruby Dropbox Gem

An easy-to-use third-party interface to the RESTful Dropbox API.

== Installation

 gem install dropbox

== Tutorial by Example

First things first: Be sure you've gotten a consumer key and secret from
http://developers.dropbox.com

 # STEP 1: Authorize the user
 session = Dropbox::Session.new('your_consumer_key', 'your_consumer_secret')
 session.mode = :sandbox # might need to set this to :dropbox; consult your API account page
 puts "Visit #{session.authorize_url} to log in to Dropbox. Hit enter when you have done this."
 gets
 session.authorize

 # STEP 2: Play!
 session.upload('testfile.txt', '/')
 uploaded_file = session.file('testfile.txt')
 puts uploaded_file.metadata.size

 uploaded_file.move 'new_name.txt'
 uploaded_file.delete

== Tutorial by Example, Rails Edition

A simple Rails controller that allows a user to first authorize their Dropbox
account, and then upload a file to their Dropbox.

 class DropboxController < ApplicationController
   def authorize
     if params[:oauth_token] then
       dropbox_session = Dropbox::Session.deserialize(session[:dropbox_session])
       dropbox_session.authorize(params)
       session[:dropbox_session] = dropbox_session.serialize # re-serialize the authenticated session

       redirect_to :action => 'upload'
     else
       dropbox_session = Dropbox::Session.new('your_consumer_key', 'your_consumer_secret')
       session[:dropbox_session] = dropbox_session.serialize
       redirect_to dropbox_session.authorize_url(:oauth_callback => url_for(:action => 'authorize'))
     end<commit_msg>added to the basic example to illustrate how serializing the session works<commit_after>= Ruby Dropbox Gem

An easy-to-use third-party interface to the RESTful Dropbox API.

== Installation

 gem install dropbox

== Tutorial by Example

First things first: Be sure you've gotten a consumer key and secret from
http://developers.dropbox.com

 # STEP 1: Authorize the user
 session = Dropbox::Session.new('your_consumer_key', 'your_consumer_secret')
 session.mode = :sandbox # might need to set this to :dropbox; consult your API account page
 puts "Visit #{session.authorize_url} to log in to Dropbox. Hit enter when you have done this."
 gets
 session.authorize

 # STEP 2: Play!
 session.upload('testfile.txt', '/')
 uploaded_file = session.file('testfile.txt')
 puts uploaded_file.metadata.size

 uploaded_file.move 'new_name.txt'
 uploaded_file.delete

 # STEP 3: Save session for later
 File.open('serialized_session.txt', 'w') do |f|
   f.puts session.serialize
 end

 # STEP 4: Play with saved session!
 new_session = Dropbox::Session.deserialize(File.read('serialized_session.txt'))
 account = new_session.account
 puts account.display_name

== Tutorial by Example, Rails Edition

A simple Rails controller that allows a user to first authorize their Dropbox
account, and then upload a file to their Dropbox.

 class DropboxController < ApplicationController
   def authorize
     if params[:oauth_token] then
       dropbox_session = Dropbox::Session.deserialize(session[:dropbox_session])
       dropbox_session.authorize(params)
       session[:dropbox_session] = dropbox_session.serialize # re-serialize the authenticated session

       redirect_to :action => 'upload'
     else
       dropbox_session = Dropbox::Session.new('your_consumer_key', 'your_consumer_secret')
       session[:dropbox_session] = dropbox_session.serialize
       redirect_to dropbox_session.authorize_url(:oauth_callback => url_for(:action => 'authorize'))
     end
{'fraction_non_alphanumeric': 0.08591549295774648, 'fraction_numerical': 0.0016901408450704226, 'mean_word_length': 4.618670886075949, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '443912', 'n_tokens_mistral': 1033, 'n_tokens_neox': 980, 'n_words': 319}