box-api 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,24 +1,26 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- box-api (0.1.8)
5
- httmultiparty (~> 0.3)
4
+ box-api (0.1.9)
5
+ httmultiparty (~> 0.3.6)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
10
  configuration (1.3.1)
11
- crack (0.1.8)
12
11
  diff-lcs (1.1.2)
13
- httmultiparty (0.3)
12
+ httmultiparty (0.3.6)
14
13
  httparty (>= 0.7.3)
15
14
  multipart-post
16
- httparty (0.7.8)
17
- crack (= 0.1.8)
15
+ httparty (0.8.1)
16
+ multi_json
17
+ multi_xml
18
18
  launchy (0.4.0)
19
19
  configuration (>= 0.0.5)
20
20
  rake (>= 0.8.1)
21
- multipart-post (1.1.2)
21
+ multi_json (1.0.3)
22
+ multi_xml (0.4.1)
23
+ multipart-post (1.1.3)
22
24
  rake (0.9.2)
23
25
  rspec (2.6.0)
24
26
  rspec-core (~> 2.6.0)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "box-api"
3
- s.version = "0.1.8"
3
+ s.version = "0.1.9"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.authors = ["Box.net", "Luke Curley"]
6
6
  s.email = ["luke@box.net"]
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
14
14
  s.require_paths = [ "lib", "spec" ]
15
15
 
16
- s.add_dependency("httmultiparty", "~> 0.3")
16
+ s.add_dependency("httmultiparty", "~> 0.3.6")
17
17
 
18
18
  s.add_development_dependency("launchy") # only used in examples
19
19
  s.add_development_dependency("rake")
@@ -271,20 +271,22 @@ module Box
271
271
 
272
272
  # Upload the file to the specified folder.
273
273
  #
274
- # @param [String] path Upload the file at the given path.
274
+ # @param [String, File or UploadIO] path Upload the file at the given path, or a File or UploadIO object..
275
275
  # @param [String] folder_id The folder id of the parent folder to use.
276
276
  # @param [Optional, Boolean] new_copy Upload a new copy instead of overwriting.
277
277
  def upload(path, folder_id, new_copy = false)
278
- query_upload('upload', folder_id, 'upload_ok', :file => ::File.new(path), :new_copy => new_copy)
278
+ path = ::File.new(path) unless path.is_a?(::UploadIO) or path.is_a?(::File)
279
+ query_upload('upload', folder_id, 'upload_ok', :file => path, :new_copy => new_copy)
279
280
  end
280
281
 
281
282
  # Overwrite the given file with a new one.
282
283
  #
283
- # @param [String] path (see #upload)
284
+ # @param [String, File or UploadIO] path (see #upload)
284
285
  # @param [String] file_id Replace the file with this id.
285
286
  # @param [Optional, String] name Use a new name as well.
286
287
  def overwrite(path, file_id, name = nil)
287
- query_upload('overwrite', file_id, 'upload_ok', :file => ::File.new(path), :file_name => name)
288
+ path = ::File.new(path) unless path.is_a?(::UploadIO) or path.is_a?(::File)
289
+ query_upload('overwrite', file_id, 'upload_ok', :file => path, :file_name => name)
288
290
  end
289
291
 
290
292
  # Upload a new copy of the given file.
@@ -90,6 +90,22 @@ describe Box::File do
90
90
  clone.should_not be @dummy
91
91
  end
92
92
 
93
+ it "uploads a File object" do
94
+ @test_temp = @test_root.create('temp')
95
+ File.open(@vegetables) do |f|
96
+ @test_temp.upload(f)
97
+ end
98
+ @test_temp.files.should have(1).things
99
+ end
100
+
101
+ it "uploads an UploadIO object" do
102
+ @test_temp = @test_root.create('temp2')
103
+ File.open(@vegetables) do |f|
104
+ @test_temp.upload(UploadIO.new(f, 'text/plain', 'i_am_only_a_uploadio.txt'))
105
+ end
106
+ @test_temp.files.should have(1).things
107
+ end
108
+
93
109
  it "renames a file" do
94
110
  @dummy.rename('bandito.txt')
95
111
  @dummy.name.should == 'bandito.txt'
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: box-api
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.8
5
+ version: 0.1.9
6
6
  platform: ruby
7
7
  authors:
8
8
  - Box.net
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-08-15 00:00:00 -07:00
14
+ date: 2011-10-31 00:00:00 -07:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
@@ -21,7 +21,7 @@ dependencies:
21
21
  requirements:
22
22
  - - ~>
23
23
  - !ruby/object:Gem::Version
24
- version: "0.3"
24
+ version: 0.3.6
25
25
  type: :runtime
26
26
  prerelease: false
27
27
  version_requirements: *id001
@@ -146,7 +146,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
146
146
  requirements:
147
147
  - - ">="
148
148
  - !ruby/object:Gem::Version
149
- hash: 2606524952571599279
149
+ hash: 3045908204068535320
150
150
  segments:
151
151
  - 0
152
152
  version: "0"
@@ -155,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
155
  requirements:
156
156
  - - ">="
157
157
  - !ruby/object:Gem::Version
158
- hash: 2606524952571599279
158
+ hash: 3045908204068535320
159
159
  segments:
160
160
  - 0
161
161
  version: "0"