Module: Dropbox

Defined in:
lib/dropbox.rb,
lib/dropbox/api.rb,
lib/dropbox/entry.rb,
lib/dropbox/event.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 collapse

VERSION =

The API version this client works with.

"0"
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

.api_url(*paths_and_options) ⇒ Object

:nodoc:



47
48
49
50
51
52
53
54
55
# File 'lib/dropbox.rb', line 47

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

.check_path(path) ⇒ Object

:nodoc:

Raises:

  • (ArgumentError)


57
58
59
60
61
# File 'lib/dropbox.rb', line 57

def self.check_path(path) # :nodoc:
  raise ArgumentError, "Backslashes are not allowed in Dropbox paths" if path.include?('\\')
  raise ArgumentError, "Dropbox paths are limited to 256 characters in length" if path.size > 256
  return path
end