Module: Dropbox

Defined in:
lib/dropbox.rb,
lib/dropbox/api.rb,
lib/dropbox/event.rb,
lib/dropbox/entry.rb,
lib/dropbox/session.rb,
lib/dropbox/revision.rb,
lib/dropbox/memoization.rb

Overview

doc fix

Defined Under Namespace

Modules: API, Memoization Classes: APIError, AlreadyAuthorizedError, Entry, Event, FileError, FileExistsError, FileNotFoundError, NotLoadedError, ParseError, PingbackError, Revision, Session, TooManyEntriesError, UnauthorizedError, UnsuccessfulResponseError

Constant Summary

VERSION =

The API version this client works with.

"0"
AUTH_HOST =

The host to authenticate user.

"http://www.dropbox.com"
AUTH_SSL_HOST =

The SSL host to authenticate user.

"https://www.dropbox.com"
HOST =

The host serving API requests.

"http://api.dropbox.com"
SSL_HOST =

The SSL host serving API requests.

"https://api.dropbox.com"
ALTERNATE_HOSTS =

Alternate hosts for other API requests.

{
  'event_content' => 'http://api-content.dropbox.com',
  'files' => 'http://api-content.dropbox.com',
  'thumbnails' => 'http://api-content.dropbox.com'
}
ALTERNATE_SSL_HOSTS =

Alternate SSL hosts for other API requests.

{
  'event_content' => 'https://api-content.dropbox.com',
  'files' => 'https://api-content.dropbox.com',
  'thumbnails' => 'https://api-content.dropbox.com'
}

Class Method Summary (collapse)

Class Method Details

+ (Object) api_url(*paths_and_options)

:nodoc:



51
52
53
54
55
56
57
58
59
# File 'lib/dropbox.rb', line 51

def self.api_url(*paths_and_options) # :nodoc:
  params = paths_and_options.extract_options!
  ssl = params.delete(:ssl)
  host = (ssl ? ALTERNATE_SSL_HOSTS[paths_and_options.first] : ALTERNATE_HOSTS[paths_and_options.first]) || (ssl ? SSL_HOST : HOST)
  url = "#{host}/#{VERSION}/#{paths_and_options.map { |path_elem| CGI.escape path_elem.to_s }.join('/')}"
  url.gsub! '+', '%20' # dropbox doesn't really like plusses
  url << "?#{params.map { |k,v| CGI.escape(k.to_s) + "=" + CGI.escape(v.to_s) }.join('&')}" unless params.empty?
  return url
end

+ (Object) check_path(path)

:nodoc:

Raises:

  • (ArgumentError)


61
62
63
64
65
# File 'lib/dropbox.rb', line 61

def self.check_path(path) # :nodoc:
  raise ArgumentError, "Backslashes are not allowed in Dropbox paths" if path.include?('\\')
  raise ArgumentError, "File names are limited to 255 characters" if path.split('/').last.size > 255 unless path.empty?
  return path
end