dropbox-api 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e1474a34de5bf86752d2a0fc373aa9d556e80cc6
4
- data.tar.gz: dc33512fa9132a5e9c12f36156328294309f2cb5
3
+ metadata.gz: 5c1d8914b2294e4ca594597d1d20589822ab8357
4
+ data.tar.gz: 1523fde081a4a3dc3a9d7b9a1db40f2d52d8ab26
5
5
  SHA512:
6
- metadata.gz: ece9abc626bfcd3f8920614b8db8de0ead7004713e33c80190ae34b47f20740ea5d9800d3fb4abb19202b1712ba2b07a5a5a3118b690dba3971056119c41b215
7
- data.tar.gz: 9ec8f8012d2a3b3967fa2d1973b9eb9dfc317abfb3f515439ed7ba3c1609468e6e365758ae2ccba5789dff1bd7855030c9e3067fbfbb94274ee290e97047a5fb
6
+ metadata.gz: f276d9a4e2684036681843c7eb62b46b374a745d3feb978714388510b52d2e5e12615dca50ff373f7b248a04bca314cd2f6e106a16757a841be1811d006fe14c
7
+ data.tar.gz: db0295a231b0cbc0ec80e26ff5c8fe7400d0b79e42842b0a7add9e2e1c0b5c4dfc7f5bbd2b18ff396e56f5b8f55d17d5abeb10f03d683020c73169fb9f21bf8c
data/Gemfile CHANGED
@@ -1,10 +1,4 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in dropbox-api.gemspec
4
- gemspec
5
-
6
- gem "rspec"
7
- gem "rake"
8
- gem 'simplecov'
9
- gem "ruby-debug19"
10
- gem "yajl-ruby"
4
+ gemspec
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011 Marcin Bunsch, Future Simple Inc.
1
+ Copyright (c) 2011-2014 Marcin Bunsch, Future Simple Inc.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person
4
4
  obtaining a copy of this software and associated documentation
@@ -19,4 +19,4 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
19
  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
20
  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
21
  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
- OTHER DEALINGS IN THE SOFTWARE.
22
+ OTHER DEALINGS IN THE SOFTWARE.
@@ -1,11 +1,11 @@
1
1
  Dropbox::API - Dropbox Ruby API client
2
2
  =========
3
3
 
4
- A Ruby client for the DropBox REST API.
4
+ A Ruby client for the Dropbox REST API.
5
5
 
6
6
  Goal:
7
7
 
8
- To deliver a more Rubyesque experience when using the DropBox API.
8
+ To deliver a more Rubyesque experience when using the Dropbox API.
9
9
 
10
10
  Current state:
11
11
 
@@ -14,11 +14,11 @@ First release, whole API covered.
14
14
  Important!!!
15
15
  ------------
16
16
 
17
- From version 0.2.0, Dropbox::API::File#delete and Dropbox::API::Dir#delete *are gone*!!
17
+ From version 0.2.0, `Dropbox::API::File#delete` and `Dropbox::API::Dir#delete` *are gone*!!
18
18
 
19
19
  The reason is that it's based on Hashie::Mash and was screwing Hash#delete.
20
20
 
21
- It is replaced with Dropbox::API::File#destroy and Dropbox::API::Dir#destroy.
21
+ It is replaced with `Dropbox::API::File#destroy` and `Dropbox::API::Dir#destroy`.
22
22
 
23
23
  Installation
24
24
  ------------
@@ -43,9 +43,10 @@ In order to use this client, you need to have an app created on https://www.drop
43
43
  Once you have it, put this configuration somewhere in your code, before you start working with the client.
44
44
 
45
45
  ```ruby
46
- Dropbox::API::Config.app_key = YOUR_APP_TOKEN
46
+ Dropbox::API::Config.app_key = YOUR_APP_KEY
47
47
  Dropbox::API::Config.app_secret = YOUR_APP_SECRET
48
- Dropbox::API::Config.mode = "sandbox" # if you have a single-directory app or "dropbox" if it has access to the whole dropbox
48
+ Dropbox::API::Config.mode = "sandbox" # if you have a single-directory app
49
+ # Dropbox::API::Config.mode = "dropbox" # if your app has access to the whole dropbox
49
50
  ```
50
51
 
51
52
  Dropbox::API::Client
@@ -54,6 +55,9 @@ Dropbox::API::Client
54
55
  The client is the base for all communication with the API and wraps around almost all calls
55
56
  available in the API.
56
57
 
58
+ Web-based Authorization
59
+ -----------------------
60
+
57
61
  In order to create a Dropbox::API::Client object, you need to have the configuration set up for OAuth.
58
62
  Second thing you need is to have the user authorize your app using OAuth. Here's a short intro
59
63
  on how to do this:
@@ -66,9 +70,11 @@ session[:token] = request_token.token
66
70
  session[:token_secret] = request_token.secret
67
71
  request_token.authorize_url(:oauth_callback => 'http://yoursite.com/callback')
68
72
  # Here the user goes to Dropbox, authorizes the app and is redirected
73
+ # This would be typically run in a Rails controller
69
74
  hash = { oauth_token: session[:token], oauth_token_secret: session[:token_secret]}
70
75
  request_token = OAuth::RequestToken.from_hash(consumer, hash)
71
- result = request_token.get_access_token(:oauth_verifier => oauth_token)
76
+ oauth_verifier = params[:oauth_verifier]
77
+ result = request_token.get_access_token(:oauth_verifier => oauth_verifier)
72
78
  ```
73
79
 
74
80
  Now that you have the oauth token and secret, you can create a new instance of the Dropbox::API::Client, like this:
@@ -85,19 +91,20 @@ Dropbox::API supplies you with a helper rake which will authorize a single clien
85
91
  In order to have this rake available, put this on your Rakefile:
86
92
 
87
93
  ```ruby
94
+ require "dropbox-api"
88
95
  require "dropbox-api/tasks"
89
96
  Dropbox::API::Tasks.install
90
97
  ```
91
98
 
92
99
  You will notice that you have a new rake task - dropbox:authorize
93
100
 
94
- When you call this Rake task, it will ask you to provide the consumer key and secret. Afterwards it will present you with an authorize url on Dropbox.
101
+ When you call this Rake task, it will ask you to provide the app key and app secret. Afterwards it will present you with an authorize url on Dropbox.
95
102
 
96
103
  Simply go to that url, authorize the app, then press enter in the console.
97
104
 
98
105
  The rake task will output valid ruby code which you can use to create a client.
99
106
 
100
- What differs this from the DropBox Ruby SDK?
107
+ What differs this from the Dropbox Ruby SDK?
101
108
  --------------------------------------------
102
109
 
103
110
  A few things:
@@ -240,6 +247,15 @@ delta.cursor # => 'abc123'
240
247
  delta.entries # => [#<Dropbox::API::File>, #<Dropbox::API::Dir>]
241
248
  ```
242
249
 
250
+ Optionally, you can set additional parameters, e.g. **path_prefix**. You can find all available parameters in the [Dropbox API documentation](https://www.dropbox.com/developers/core/docs#delta).
251
+
252
+ ```ruby
253
+ delta = client.delta 'abc123', path_prefix: '/Path/To/My/Folder'
254
+ delta.cursor # => 'abc123'
255
+ delta.entries # => [#<Dropbox::API::File>, #<Dropbox::API::Dir>]
256
+ ```
257
+
258
+
243
259
  Dropbox::API::File and Dropbox::API::Dir methods
244
260
  ----------------------------
245
261
 
@@ -8,14 +8,24 @@ Gem::Specification.new do |s|
8
8
  s.authors = ["Marcin Bunsch"]
9
9
  s.email = ["marcin@futuresimple.com"]
10
10
  s.homepage = "http://github.com/futuresimple/dropbox-api"
11
- s.summary = "A Ruby client for the DropBox REST API."
12
- s.description = "To deliver a more Rubyesque experience when using the DropBox API."
11
+ s.summary = "A Ruby client for the Dropbox REST API."
12
+ s.description = "To deliver a more Rubyesque experience when using the Dropbox API."
13
+ s.license = 'MIT'
13
14
 
14
15
  s.rubyforge_project = "dropbox-api"
15
16
 
16
- s.add_dependency 'multi_json'
17
- s.add_dependency 'oauth'
18
- s.add_dependency 'hashie'
17
+ s.add_dependency 'multi_json', '~> 1.7.9'
18
+ s.add_dependency 'oauth', '~> 0.4.7'
19
+ s.add_dependency 'hashie', '~> 2.0.5'
20
+
21
+ s.add_development_dependency 'rspec','2.14.1'
22
+ s.add_development_dependency 'rake', '10.1.0'
23
+ s.add_development_dependency 'simplecov', '~> 0.8.2'
24
+ s.add_development_dependency 'yajl-ruby', '~> 1.2.0'
25
+
26
+ if RUBY_VERSION < "1.9"
27
+ s.add_development_dependency 'ruby-debug19'
28
+ end
19
29
 
20
30
  s.files = `git ls-files`.split("\n")
21
31
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -44,10 +44,10 @@ module Dropbox
44
44
  Dropbox::API::Object.convert(results, self)
45
45
  end
46
46
 
47
- def delta(cursor=nil)
47
+ def delta(cursor=nil, options={})
48
48
  entries = []
49
49
  has_more = true
50
- params = cursor ? {:cursor => cursor} : {}
50
+ params = cursor ? options.merge(:cursor => cursor) : options
51
51
  while has_more
52
52
  response = raw.delta(params)
53
53
  params[:cursor] = response['cursor']
@@ -12,9 +12,9 @@ module Dropbox
12
12
  task :authorize do
13
13
  require "dropbox-api"
14
14
  require "cgi"
15
- print "Enter consumer key: "
15
+ print "Enter dropbox app key: "
16
16
  consumer_key = $stdin.gets.chomp
17
- print "Enter consumer secret: "
17
+ print "Enter dropbox app secret: "
18
18
  consumer_secret = $stdin.gets.chomp
19
19
 
20
20
  Dropbox::API::Config.app_key = consumer_key
@@ -1,5 +1,5 @@
1
1
  module Dropbox
2
2
  module API
3
- VERSION = "0.4.2"
3
+ VERSION = "0.4.3"
4
4
  end
5
5
  end
@@ -143,10 +143,10 @@ describe Dropbox::API::Client do
143
143
  it "copies a file from a copy_ref" do
144
144
  filename = "test/searchable-test-#{Dropbox::Spec.namespace}.txt"
145
145
  @client.upload filename, "Some file"
146
- response = @client.search "searchable-test-#{Dropbox::Spec.namespace}", :path => 'test'
146
+ response = @client.search "searchable-test-#{Dropbox::Spec.namespace}", :path => 'test'
147
147
  ref = response.first.copy_ref['copy_ref']
148
148
  @client.copy_from_copy_ref ref, "#{filename}.copied"
149
- response = @client.search "searchable-test-#{Dropbox::Spec.namespace}.txt.copied", :path => 'test'
149
+ response = @client.search "searchable-test-#{Dropbox::Spec.namespace}.txt.copied", :path => 'test'
150
150
  response.size.should == 1
151
151
  response.first.class.should == Dropbox::API::File
152
152
  end
@@ -196,6 +196,28 @@ describe Dropbox::API::Client do
196
196
  files.first.path.should == delete_filename
197
197
  files.last.path.should == filename
198
198
  end
199
+
200
+ context "with extra params" do
201
+
202
+ let(:response) do
203
+ {
204
+ 'cursor' => nil,
205
+ 'has_more' => false,
206
+ 'entries' => []
207
+ }
208
+ end
209
+
210
+ let(:params) do
211
+ { :path_prefix => 'my_path' }
212
+
213
+ end
214
+
215
+ it "passes them to raw delta" do
216
+ @client.raw.should_receive(:delta).with(params).and_return(response)
217
+ @client.delta nil, params
218
+ end
219
+
220
+ end
199
221
  end
200
222
 
201
223
  end
@@ -21,7 +21,7 @@ describe Dropbox::API::File do
21
21
  end
22
22
 
23
23
  end
24
-
24
+
25
25
  describe "#move" do
26
26
 
27
27
  it "moves the file properly" do
@@ -85,22 +85,22 @@ describe Dropbox::API::File do
85
85
 
86
86
  result = @file.share_url
87
87
  result.should be_an_instance_of(Dropbox::API::Object)
88
- result.keys.sort.should == ['expires', 'url']
88
+ result.keys.sort.should == ['expires', 'url', 'visibility']
89
89
 
90
90
  end
91
91
 
92
92
  end
93
93
 
94
94
  describe "#copy_ref" do
95
-
95
+
96
96
  it "returns a copy_ref object" do
97
-
97
+
98
98
  result = @file.copy_ref
99
99
  result.should be_an_instance_of(Dropbox::API::Object)
100
100
  result.keys.sort.should == ['copy_ref', 'expires']
101
-
101
+
102
102
  end
103
-
103
+
104
104
  end
105
105
 
106
106
  describe "#direct_url" do
metadata CHANGED
@@ -1,66 +1,122 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dropbox-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcin Bunsch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-10 00:00:00.000000000 Z
11
+ date: 2014-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 1.7.9
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 1.7.9
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: oauth
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 0.4.7
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 0.4.7
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: hashie
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 2.0.5
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
55
- description: To deliver a more Rubyesque experience when using the DropBox API.
54
+ version: 2.0.5
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 2.14.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 2.14.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 10.1.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 10.1.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.8.2
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.8.2
97
+ - !ruby/object:Gem::Dependency
98
+ name: yajl-ruby
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 1.2.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 1.2.0
111
+ description: To deliver a more Rubyesque experience when using the Dropbox API.
56
112
  email:
57
113
  - marcin@futuresimple.com
58
114
  executables: []
59
115
  extensions: []
60
116
  extra_rdoc_files: []
61
117
  files:
62
- - .gitignore
63
- - .rspec
118
+ - ".gitignore"
119
+ - ".rspec"
64
120
  - Gemfile
65
121
  - LICENSE
66
122
  - README.markdown
@@ -95,7 +151,8 @@ files:
95
151
  - spec/support/config.rb
96
152
  - spec/support/jpeg.rb
97
153
  homepage: http://github.com/futuresimple/dropbox-api
98
- licenses: []
154
+ licenses:
155
+ - MIT
99
156
  metadata: {}
100
157
  post_install_message:
101
158
  rdoc_options: []
@@ -103,20 +160,20 @@ require_paths:
103
160
  - lib
104
161
  required_ruby_version: !ruby/object:Gem::Requirement
105
162
  requirements:
106
- - - '>='
163
+ - - ">="
107
164
  - !ruby/object:Gem::Version
108
165
  version: '0'
109
166
  required_rubygems_version: !ruby/object:Gem::Requirement
110
167
  requirements:
111
- - - '>='
168
+ - - ">="
112
169
  - !ruby/object:Gem::Version
113
170
  version: '0'
114
171
  requirements: []
115
172
  rubyforge_project: dropbox-api
116
- rubygems_version: 2.0.5
173
+ rubygems_version: 2.2.2
117
174
  signing_key:
118
175
  specification_version: 4
119
- summary: A Ruby client for the DropBox REST API.
176
+ summary: A Ruby client for the Dropbox REST API.
120
177
  test_files:
121
178
  - spec/connection.sample.yml
122
179
  - spec/fixtures/dropbox.jpg
@@ -129,4 +186,3 @@ test_files:
129
186
  - spec/spec_helper.rb
130
187
  - spec/support/config.rb
131
188
  - spec/support/jpeg.rb
132
- has_rdoc: