dropbox-api 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0b39a154cb174d0b3520dc9388ada41a6f240663
4
+ data.tar.gz: 46bfdad313fdc0d25ff8ab582a881991f4df4c90
5
+ SHA512:
6
+ metadata.gz: b506b52182090323076304f8f3218083e010862d6cdf0f23a501982a9fcf5e00b4675fea6df1d867de327384e899c9eb31869447ac33108348c3f506d42e8a03
7
+ data.tar.gz: 047377b42883b1b505c0a62955cb5c6d3f111d74fb16ac9839b79e5f20ba062f77faa51b8615dd735ae8d585ca97a385e1bedbd3792cc437223fd0487bc41b21
data/README.markdown CHANGED
@@ -61,16 +61,20 @@ on how to do this:
61
61
  ```ruby
62
62
  consumer = Dropbox::API::OAuth.consumer(:authorize)
63
63
  request_token = consumer.get_request_token
64
+ # Store the token and secret so after redirecting we have the same request token
65
+ session[:token] = request_token.token
66
+ session[:token_secret] = request_token.secret
64
67
  request_token.authorize_url(:oauth_callback => 'http://yoursite.com/callback')
65
68
  # Here the user goes to Dropbox, authorizes the app and is redirected
66
- # The oauth_token will be available in the params
67
- request_token.get_access_token(:oauth_verifier => oauth_token)
69
+ hash = { oauth_token: session[:token], oauth_token_secret: session[:token_secret]}
70
+ request_token = OAuth::RequestToken.from_hash(consumer, hash)
71
+ result = request_token.get_access_token(:oauth_verifier => oauth_token)
68
72
  ```
69
73
 
70
74
  Now that you have the oauth token and secret, you can create a new instance of the Dropbox::API::Client, like this:
71
75
 
72
76
  ```ruby
73
- client = Dropbox::API::Client.new :token => token, :secret => secret
77
+ client = Dropbox::API::Client.new :token => result.token, :secret => result.secret
74
78
  ```
75
79
 
76
80
  Rake-based authorization
@@ -206,7 +210,7 @@ client.download 'file.txt' # => 'file body'
206
210
 
207
211
  When provided a pattern, returns a list of files or directories within that path
208
212
 
209
- Be default is searches the root path:
213
+ By default it searches the root path:
210
214
 
211
215
  ```ruby
212
216
  client.search 'pattern' # => [#<Dropbox::API::File>, #<Dropbox::API::Dir>]
@@ -1,14 +1,14 @@
1
1
  module Dropbox
2
2
  module API
3
3
 
4
- class Error < Exception
4
+ class Error < StandardError
5
5
 
6
- class ConnectionFailed < Exception; end
7
- class Config < Exception; end
8
- class Unauthorized < Exception; end
9
- class Forbidden < Exception; end
10
- class NotFound < Exception; end
11
- class Redirect < Exception; end
6
+ class ConnectionFailed < Error; end
7
+ class Config < Error; end
8
+ class Unauthorized < Error; end
9
+ class Forbidden < Error; end
10
+ class NotFound < Error; end
11
+ class Redirect < Error; end
12
12
 
13
13
  end
14
14
 
@@ -1,5 +1,5 @@
1
1
  module Dropbox
2
2
  module API
3
- VERSION = "0.3.2"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
@@ -79,4 +79,22 @@ describe Dropbox::API::Connection do
79
79
  end
80
80
 
81
81
  end
82
+
83
+ describe "errors" do
84
+
85
+ it "recovers error with rescue statement modifier" do
86
+ expect { raise Dropbox::API::Error rescue nil }.to_not raise_error(Dropbox::API::Error)
87
+ end
88
+
89
+ it "recovers any kind of errors with the generic error" do
90
+ expect do
91
+ begin
92
+ raise Dropbox::API::Error::Forbidden
93
+ rescue Dropbox::API::Error
94
+ end
95
+ end.to_not raise_error
96
+ end
97
+
98
+ end
99
+
82
100
  end
data/spec/spec_helper.rb CHANGED
@@ -20,8 +20,8 @@ Dir.glob("#{File.dirname(__FILE__)}/support/*.rb").each { |f| require f }
20
20
  # Clean up after specs, remove test-directory
21
21
  RSpec.configure do |config|
22
22
  config.after(:all) do
23
- test_dir = Dropbox::Spec.instance.find(Dropbox::Spec.test_dir)
24
- test_dir.destroy unless test_dir.is_deleted?
23
+ test_dir = Dropbox::Spec.instance.find(Dropbox::Spec.test_dir) rescue nil
24
+ test_dir.destroy if test_dir and !test_dir.is_deleted?
25
25
  end
26
26
  end
27
27
 
metadata CHANGED
@@ -1,62 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dropbox-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
5
- prerelease:
4
+ version: 0.4.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Marcin Bunsch
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-08-31 00:00:00.000000000 Z
11
+ date: 2013-09-04 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: multi_json
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: oauth
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: hashie
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  description: To deliver a more Rubyesque experience when using the DropBox API.
@@ -103,27 +96,26 @@ files:
103
96
  - spec/support/jpeg.rb
104
97
  homepage: http://github.com/futuresimple/dropbox-api
105
98
  licenses: []
99
+ metadata: {}
106
100
  post_install_message:
107
101
  rdoc_options: []
108
102
  require_paths:
109
103
  - lib
110
104
  required_ruby_version: !ruby/object:Gem::Requirement
111
- none: false
112
105
  requirements:
113
- - - ! '>='
106
+ - - '>='
114
107
  - !ruby/object:Gem::Version
115
108
  version: '0'
116
109
  required_rubygems_version: !ruby/object:Gem::Requirement
117
- none: false
118
110
  requirements:
119
- - - ! '>='
111
+ - - '>='
120
112
  - !ruby/object:Gem::Version
121
113
  version: '0'
122
114
  requirements: []
123
115
  rubyforge_project: dropbox-api
124
- rubygems_version: 1.8.24
116
+ rubygems_version: 2.0.5
125
117
  signing_key:
126
- specification_version: 3
118
+ specification_version: 4
127
119
  summary: A Ruby client for the DropBox REST API.
128
120
  test_files:
129
121
  - spec/connection.sample.yml