ruby-box 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/README.markdown +8 -0
- data/VERSION +1 -1
- data/lib/ruby-box/file.rb +17 -1
- data/ruby-box.gemspec +2 -2
- data/spec/integration_spec.rb +48 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MDBhNGIyNTBjOWFiMzI2NjFlY2U4YTRlMjcyNWYzN2FlNWZiOWFmNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NThlNGEwMjU1YzU2MDU0ZTg4Nzg3MDU2Y2I0NDlmZWVhYmVhZTg3ZA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NzE0Y2EwNmUyZTViN2MxY2U4NDdhZWY1MjBhYTA1NDkxY2EzYzQ5ZGM4NzZk
|
10
|
+
MmQ0YTM2MjBkZTE2ZTU1OTA0NGRhZDRlNzFlMDU2NDQ1ODRlNjA2ZjYzYTU4
|
11
|
+
NmQ1MzM5ZGVlMDgyNzNlNTI3YzkyNWIwMTE3MTZiMGVhOGE3NDA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YmMyYWZhNDg2YWQwNTExN2E3NTA0ZGFhOTJhOGE1NTIwZmVlOGI0MmJjYzE1
|
14
|
+
NzgzNDdkMmZiNTY0YzgwYjNiYzcyYzEzYzg4OGZhYmY1NjUyMmExYzIxNDky
|
15
|
+
M2NiMDJjOWJkZmM5ZDRlMzYwNGU4NGMzMzFlMWU0ZTJkODRiN2I=
|
data/README.markdown
CHANGED
@@ -147,6 +147,14 @@ file = client.file('/image_folder/an-image.jpg').create_shared_link
|
|
147
147
|
p file.shared_link.url # https://www.box.com/s/d6de3224958c1755412
|
148
148
|
```
|
149
149
|
|
150
|
+
* Copying a file to another folder.
|
151
|
+
|
152
|
+
```ruby
|
153
|
+
file = client.file('/image_folder/an-image.jpg')
|
154
|
+
folder = client.folder('image_folder')
|
155
|
+
file.copy_to(folder)
|
156
|
+
```
|
157
|
+
|
150
158
|
Search
|
151
159
|
------
|
152
160
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.7.0
|
data/lib/ruby-box/file.rb
CHANGED
@@ -7,6 +7,22 @@ module RubyBox
|
|
7
7
|
resp = stream.read
|
8
8
|
end
|
9
9
|
|
10
|
+
def copy_to( folder_id, name=nil )
|
11
|
+
|
12
|
+
# Allow either a folder_id or a folder object
|
13
|
+
# to be passed in.
|
14
|
+
folder_id = folder_id.id if folder_id.instance_of?(RubyBox::Folder)
|
15
|
+
|
16
|
+
uri = URI.parse( "#{RubyBox::API_URL}/#{resource_name}/#{id}/copy" )
|
17
|
+
request = Net::HTTP::Post.new( uri.request_uri )
|
18
|
+
request.body = JSON.dump({
|
19
|
+
"parent" => {"id" => folder_id},
|
20
|
+
"name" => name
|
21
|
+
})
|
22
|
+
|
23
|
+
resp = @session.request(uri, request)
|
24
|
+
end
|
25
|
+
|
10
26
|
def stream( opts={} )
|
11
27
|
url = "#{RubyBox::API_URL}/#{resource_name}/#{id}/content"
|
12
28
|
@session.do_stream( url, opts )
|
@@ -67,4 +83,4 @@ module RubyBox
|
|
67
83
|
end
|
68
84
|
|
69
85
|
end
|
70
|
-
end
|
86
|
+
end
|
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.
|
8
|
+
s.version = "1.7.0"
|
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-07-
|
12
|
+
s.date = "2013-07-19"
|
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
@@ -227,5 +227,53 @@ describe RubyBox, :skip => true do
|
|
227
227
|
file.delete
|
228
228
|
end
|
229
229
|
end
|
230
|
+
|
231
|
+
describe "#copy_to" do
|
232
|
+
it "it copies a file to a folder when a folder id is passed in" do
|
233
|
+
file = @client.upload_file('spec/fixtures/遠志教授.jpg', '/ruby-box_gem_testing/')
|
234
|
+
folder = @client.folder('/ruby-box_gem_testing/cool stuff/')
|
235
|
+
|
236
|
+
file.copy_to(folder.id)
|
237
|
+
|
238
|
+
copied_file = @client.file('/ruby-box_gem_testing/cool stuff/遠志教授.jpg')
|
239
|
+
|
240
|
+
copied_file.name.should == file.name
|
241
|
+
copied_file.size.should == file.size
|
242
|
+
|
243
|
+
file.delete
|
244
|
+
copied_file.delete
|
245
|
+
end
|
246
|
+
|
247
|
+
it "it copies a file to a folder when a folder is passed in" do
|
248
|
+
file = @client.upload_file('spec/fixtures/遠志教授.jpg', '/ruby-box_gem_testing/')
|
249
|
+
folder = @client.folder('/ruby-box_gem_testing/cool stuff/')
|
250
|
+
|
251
|
+
file.copy_to(folder)
|
252
|
+
|
253
|
+
copied_file = @client.file('/ruby-box_gem_testing/cool stuff/遠志教授.jpg')
|
254
|
+
|
255
|
+
copied_file.name.should == file.name
|
256
|
+
copied_file.size.should == file.size
|
257
|
+
|
258
|
+
file.delete
|
259
|
+
copied_file.delete
|
260
|
+
end
|
261
|
+
|
262
|
+
it "allows file to be renamed when copied" do
|
263
|
+
file = @client.upload_file('spec/fixtures/遠志教授.jpg', '/ruby-box_gem_testing/')
|
264
|
+
folder = @client.folder('/ruby-box_gem_testing/cool stuff/')
|
265
|
+
|
266
|
+
file.copy_to(folder, 'banana.jpg')
|
267
|
+
|
268
|
+
copied_file = @client.file('/ruby-box_gem_testing/cool stuff/banana.jpg')
|
269
|
+
|
270
|
+
copied_file.name.should == 'banana.jpg'
|
271
|
+
copied_file.size.should == file.size
|
272
|
+
|
273
|
+
file.delete
|
274
|
+
copied_file.delete
|
275
|
+
end
|
276
|
+
end
|
230
277
|
end
|
278
|
+
|
231
279
|
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.
|
4
|
+
version: 1.7.0
|
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-07-
|
11
|
+
date: 2013-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multipart-post
|