ruby-box 1.9.2 → 1.9.3
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/VERSION +1 -1
- data/lib/ruby-box/client.rb +4 -4
- data/lib/ruby-box/folder.rb +6 -1
- data/ruby-box.gemspec +2 -2
- data/spec/integration_spec.rb +9 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODE3OWJkYWM1ZTZkNzU5NjczZGU3Yzk5Y2I1MjZkNjhiZWI2OGIwZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NzYxZjVkNWJiZDg2MDdiYTVmMmI5ZDg3MjQwZGIzNzNiMjRiNTQxYg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZWU0ZjE0YzVjZmNiMGEyZmU3NmNiNWE2ZjRiMDlkYmIyNTY5Mjc2MTRhZTdm
|
10
|
+
NGE1NWMyZGYwNDM4MTRmZWI5ZmU5MTM4ZDYzZjQxMmJiZjBhOWQ0ODRiYjdh
|
11
|
+
NTVmNDE3OWZkNTlmZTJiZTA1NTU5MjQ2MzNkNmY0MWI5ZGYxNzc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MjVmYjNkMjQ4NmMyNmJlMDczZmY5YTQ5ODE1ZmY4MTExMTkwZWMyMWQ3ZGVm
|
14
|
+
MGRlZDlkZGJkMDM4ZDk1ZGJhZTI5ZmU4ZTk4ZDc3ZmEwOGZjYmM3YjYxYWQ1
|
15
|
+
MWIyM2Y1NDY5OTdjOWUwY2M2MzYwNWNhMzk1OWNhZWUyZjA3M2E=
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.9.
|
1
|
+
1.9.3
|
data/lib/ruby-box/client.rb
CHANGED
@@ -70,19 +70,19 @@ module RubyBox
|
|
70
70
|
folder
|
71
71
|
end
|
72
72
|
|
73
|
-
def upload_data(path, data)
|
73
|
+
def upload_data(path, data, overwrite=true)
|
74
74
|
path = split_path(path)
|
75
75
|
file_name = path.pop
|
76
76
|
folder = create_folder(path.join('/'))
|
77
|
-
folder.upload_file(file_name, data) if folder
|
77
|
+
folder.upload_file(file_name, data, overwrite) if folder
|
78
78
|
end
|
79
79
|
|
80
|
-
def upload_file(local_path, remote_path)
|
80
|
+
def upload_file(local_path, remote_path, overwrite=true)
|
81
81
|
file_name = local_path.split('/').pop
|
82
82
|
folder = create_folder( remote_path )
|
83
83
|
return unless folder
|
84
84
|
::File.open( local_path ) do |data|
|
85
|
-
folder.upload_file(file_name, data)
|
85
|
+
folder.upload_file(file_name, data, overwrite)
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
data/lib/ruby-box/folder.rb
CHANGED
@@ -13,7 +13,7 @@ module RubyBox
|
|
13
13
|
items_by_type(RubyBox::Folder, name, item_limit, offset, fields)
|
14
14
|
end
|
15
15
|
|
16
|
-
def upload_file(filename, data)
|
16
|
+
def upload_file(filename, data, overwrite=true)
|
17
17
|
file = RubyBox::File.new(@session, {
|
18
18
|
'name' => filename,
|
19
19
|
'parent' => RubyBox::User.new(@session, {'id' => id})
|
@@ -22,6 +22,11 @@ module RubyBox
|
|
22
22
|
begin
|
23
23
|
resp = file.upload_content(data) #write a new file. If there is a conflict, update the conflicted file.
|
24
24
|
rescue RubyBox::ItemNameInUse => e
|
25
|
+
|
26
|
+
# if overwrite flag is false, simply raise exception.
|
27
|
+
raise e unless overwrite
|
28
|
+
|
29
|
+
# otherwise let's attempt to overwrite the file.
|
25
30
|
data.rewind
|
26
31
|
|
27
32
|
# The Box API occasionally does not return
|
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.3"
|
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-08-
|
12
|
+
s.date = "2013-08-07"
|
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
@@ -123,6 +123,15 @@ describe RubyBox, :skip => true do
|
|
123
123
|
file.name.should == '遠志教授.jpg'
|
124
124
|
file.delete
|
125
125
|
end
|
126
|
+
|
127
|
+
it 'should raise an exception if files collide and overwrite is false' do
|
128
|
+
fdata = File.open( 'spec/fixtures/遠志教授.jpg', 'rb' )
|
129
|
+
file = @client.upload_data('/ruby-box_gem_testing/cool stuff/遠志教授.jpg', fdata)
|
130
|
+
fdata = File.open( 'spec/fixtures/遠志教授.jpg', 'rb' )
|
131
|
+
|
132
|
+
expect{ @client.upload_data('/ruby-box_gem_testing/cool stuff/遠志教授.jpg', fdata, false) }.to raise_error(RubyBox::ItemNameInUse)
|
133
|
+
file.delete
|
134
|
+
end
|
126
135
|
|
127
136
|
it "should upload a new file" do
|
128
137
|
utf8_file_name = '遠志教授.jpg'
|
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.3
|
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-08-
|
11
|
+
date: 2013-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multipart-post
|