ruby-box 1.9.1 → 1.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.markdown +8 -0
- data/VERSION +1 -1
- data/lib/ruby-box/file.rb +12 -1
- data/ruby-box.gemspec +2 -2
- data/spec/integration_spec.rb +61 -27
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NGE5MjEyYWJjNzVmNmEwZTVjNjkxODVjNDVmNzUyYzExMDU3ZjJjYw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YWFmYjlmNWQ2MmQ0YzE1YWZhZjgxOGMyYzA0NDQ3NDJjZDY4YjQwOA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZjFlN2QzYWI5MDg5MThlYzljNzg5MDJlYjgyNzg0MDQ5MGU2YzUzOWU2NDdl
|
10
|
+
YmU0MWE5MWU1NDNlMzBmNjlmNzY0YzQ3NWIxYzA4NTNlNzQzYjM1ZGM4ZGU2
|
11
|
+
YjIxNGI5MTE4YmQwMjQxZTQ4NGM1OTI4Y2Q4YTk0MjYwZDhmNTk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YzExZWI2N2ZmYTQyNWU1YjVmZWFjZjZjN2MzOWFlNDc3MjZhOTBiNTMzMGY2
|
14
|
+
OGM1NDI4MGY3MGU0YjlkM2E4ZWExZWI2MzlhMTUxNWI5YTQ0NTA4NDRmMTc3
|
15
|
+
N2JkMDFlYzJmZTc3M2E5MDcyMzRiM2U5YWRhOGViZTNlM2U2Y2M=
|
data/README.markdown
CHANGED
@@ -155,6 +155,14 @@ folder = client.folder('image_folder')
|
|
155
155
|
file.copy_to(folder)
|
156
156
|
```
|
157
157
|
|
158
|
+
* Moving a file to another folder.
|
159
|
+
|
160
|
+
```ruby
|
161
|
+
file = client.file('/image_folder/an-image.jpg')
|
162
|
+
folder = client.folder('image_folder')
|
163
|
+
file.move_to(folder)
|
164
|
+
```
|
165
|
+
|
158
166
|
* Adding a comment to a file.
|
159
167
|
|
160
168
|
```ruby
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.9.
|
1
|
+
1.9.2
|
data/lib/ruby-box/file.rb
CHANGED
@@ -7,6 +7,17 @@ module RubyBox
|
|
7
7
|
resp = stream.read
|
8
8
|
end
|
9
9
|
|
10
|
+
def move_to( folder_id, name=nil )
|
11
|
+
# Allow either a folder_id or a folder object
|
12
|
+
# to be passed in.
|
13
|
+
folder_id = folder_id.id if folder_id.instance_of?(RubyBox::Folder)
|
14
|
+
|
15
|
+
self.name = name if name
|
16
|
+
self.parent = {"id" => folder_id}
|
17
|
+
|
18
|
+
update
|
19
|
+
end
|
20
|
+
|
10
21
|
def copy_to( folder_id, name=nil )
|
11
22
|
|
12
23
|
# Allow either a folder_id or a folder object
|
@@ -82,7 +93,7 @@ module RubyBox
|
|
82
93
|
end
|
83
94
|
|
84
95
|
def update_fields
|
85
|
-
['name', 'description']
|
96
|
+
['name', 'description', 'parent']
|
86
97
|
end
|
87
98
|
|
88
99
|
def prepare_upload(data, fname)
|
data/ruby-box.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "ruby-box"
|
8
|
-
s.version = "1.9.
|
8
|
+
s.version = "1.9.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Attachments.me"]
|
12
|
-
s.date = "2013-
|
12
|
+
s.date = "2013-08-05"
|
13
13
|
s.description = "ruby gem for box.com 2.0 api"
|
14
14
|
s.email = "ben@attachments.me"
|
15
15
|
s.extra_rdoc_files = [
|
data/spec/integration_spec.rb
CHANGED
@@ -239,50 +239,84 @@ describe RubyBox, :skip => true do
|
|
239
239
|
|
240
240
|
describe "#copy_to" do
|
241
241
|
it "it copies a file to a folder when a folder id is passed in" do
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
242
|
+
file = @client.upload_file('spec/fixtures/遠志教授.jpg', '/ruby-box_gem_testing/')
|
243
|
+
folder = @client.folder('/ruby-box_gem_testing/cool stuff/')
|
244
|
+
|
245
|
+
file.copy_to(folder.id)
|
246
246
|
|
247
|
-
|
247
|
+
copied_file = @client.file('/ruby-box_gem_testing/cool stuff/遠志教授.jpg')
|
248
248
|
|
249
|
-
|
250
|
-
|
249
|
+
copied_file.name.should == file.name
|
250
|
+
copied_file.size.should == file.size
|
251
251
|
|
252
|
-
|
253
|
-
|
252
|
+
file.delete
|
253
|
+
copied_file.delete
|
254
254
|
end
|
255
255
|
|
256
256
|
it "it copies a file to a folder when a folder is passed in" do
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
257
|
+
file = @client.upload_file('spec/fixtures/遠志教授.jpg', '/ruby-box_gem_testing/')
|
258
|
+
folder = @client.folder('/ruby-box_gem_testing/cool stuff/')
|
259
|
+
|
260
|
+
file.copy_to(folder)
|
261
261
|
|
262
|
-
|
262
|
+
copied_file = @client.file('/ruby-box_gem_testing/cool stuff/遠志教授.jpg')
|
263
263
|
|
264
|
-
|
265
|
-
|
264
|
+
copied_file.name.should == file.name
|
265
|
+
copied_file.size.should == file.size
|
266
266
|
|
267
|
-
|
268
|
-
|
267
|
+
file.delete
|
268
|
+
copied_file.delete
|
269
269
|
end
|
270
270
|
|
271
271
|
it "allows file to be renamed when copied" do
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
272
|
+
file = @client.upload_file('spec/fixtures/遠志教授.jpg', '/ruby-box_gem_testing/')
|
273
|
+
folder = @client.folder('/ruby-box_gem_testing/cool stuff/')
|
274
|
+
|
275
|
+
file.copy_to(folder, 'banana.jpg')
|
276
276
|
|
277
|
-
|
277
|
+
copied_file = @client.file('/ruby-box_gem_testing/cool stuff/banana.jpg')
|
278
278
|
|
279
|
-
|
280
|
-
|
279
|
+
copied_file.name.should == 'banana.jpg'
|
280
|
+
copied_file.size.should == file.size
|
281
281
|
|
282
|
-
|
283
|
-
|
282
|
+
file.delete
|
283
|
+
copied_file.delete
|
284
284
|
end
|
285
285
|
end
|
286
|
+
|
287
|
+
describe "#move_to" do
|
288
|
+
it "it moves a file to a folder, the original no longer exists" do
|
289
|
+
file = @client.upload_file('spec/fixtures/遠志教授.jpg', '/ruby-box_gem_testing/')
|
290
|
+
folder = @client.folder('/ruby-box_gem_testing/cool stuff/')
|
291
|
+
|
292
|
+
file.move_to(folder.id)
|
293
|
+
original_file = @client.file('/ruby-box_gem_testing/遠志教授.jpg')
|
294
|
+
original_file.should == nil # the original should no longer exist.
|
295
|
+
|
296
|
+
moved_file = @client.file('/ruby-box_gem_testing/cool stuff/遠志教授.jpg')
|
297
|
+
moved_file.name.should == file.name # the file should exist in the new location.
|
298
|
+
moved_file.size.should == file.size
|
299
|
+
|
300
|
+
moved_file.delete
|
301
|
+
end
|
302
|
+
|
303
|
+
it "allows file to be renamed when moved" do
|
304
|
+
file = @client.upload_file('spec/fixtures/遠志教授.jpg', '/ruby-box_gem_testing/')
|
305
|
+
folder = @client.folder('/ruby-box_gem_testing/cool stuff/')
|
306
|
+
|
307
|
+
file.move_to(folder, 'banana.jpg')
|
308
|
+
original_file = @client.file('/ruby-box_gem_testing/遠志教授.jpg')
|
309
|
+
original_file.should == nil # the original should no longer exist.
|
310
|
+
|
311
|
+
moved_file = @client.file('/ruby-box_gem_testing/cool stuff/banana.jpg')
|
312
|
+
moved_file.name.should == 'banana.jpg' # the file should exist in the new location.
|
313
|
+
moved_file.size.should == file.size
|
314
|
+
|
315
|
+
moved_file.delete
|
316
|
+
end
|
317
|
+
|
318
|
+
end
|
319
|
+
|
286
320
|
end
|
287
321
|
|
288
322
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-box
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.
|
4
|
+
version: 1.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Attachments.me
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multipart-post
|