rackspace-cloudfiles 1.3.0.2 → 1.3.0.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.
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'rubygems'
2
- gem 'echoe', '~> 3.0.1'
2
+ gem 'echoe', '>= 3.0.1'
3
3
  require 'echoe'
4
4
  require './lib/cloudfiles.rb'
5
5
 
data/cloudfiles.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{cloudfiles}
5
- s.version = "1.3.0.2"
5
+ s.version = "1.3.0.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["H. Wade Minter, Rackspace Hosting"]
9
- s.date = %q{2009-05-14}
9
+ s.date = %q{2009-05-16}
10
10
  s.description = %q{A Ruby version of the Mosso Cloud Files API.}
11
11
  s.email = %q{wade.minter@rackspace.com}
12
12
  s.extra_rdoc_files = ["lib/cloudfiles/authentication.rb", "lib/cloudfiles/connection.rb", "lib/cloudfiles/container.rb", "lib/cloudfiles/storage_object.rb", "lib/cloudfiles.rb", "README.rdoc", "TODO"]
data/lib/cloudfiles.rb CHANGED
@@ -18,7 +18,7 @@
18
18
  # To create a new CloudFiles connection, use the CloudFiles::Connection.new('user_name', 'api_key') method.
19
19
  module CloudFiles
20
20
 
21
- VERSION = '1.3.0.2'
21
+ VERSION = '1.3.0.3'
22
22
  require 'net/http'
23
23
  require 'net/https'
24
24
  require 'rexml/document'
@@ -211,6 +211,7 @@ module CloudFiles
211
211
  # This method actually makes the HTTP calls out to the server
212
212
  def cfreq(method,server,path,headers = {},data = nil,attempts = 0,&block) # :nodoc:
213
213
  start = Time.now
214
+ headers['Transfer-Encoding'] = "chunked" if data.is_a?(IO)
214
215
  hdrhash = headerprep(headers)
215
216
  start_http(server,path,hdrhash)
216
217
  request = Net::HTTP.const_get(method.to_s.capitalize).new(path,hdrhash)
@@ -220,7 +221,9 @@ module CloudFiles
220
221
  else
221
222
  request.body = data
222
223
  end
223
- request.content_length = data.respond_to?(:lstat) ? data.stat.size : data.size
224
+ unless data.is_a?(IO)
225
+ request.content_length = data.respond_to?(:lstat) ? data.stat.size : data.size
226
+ end
224
227
  else
225
228
  request.content_length = 0
226
229
  end
@@ -144,10 +144,17 @@ module CloudFiles
144
144
  #
145
145
  # object.data
146
146
  # => "This is new data"
147
+ #
148
+ # If you are passing your data in via STDIN, just do an
149
+ #
150
+ # object.write
151
+ #
152
+ # with no data (or, if you need to pass headers)
153
+ #
154
+ # object.write(nil,{'header' => 'value})
155
+
147
156
  def write(data=nil,headers={})
148
- #raise SyntaxException, "No data was provided for object '#{@name}'" if (data.nil?)
149
- # Try to get the content type
150
- raise SyntaxException, "No data or header updates supplied" if (data.nil? and headers.empty?)
157
+ raise SyntaxException, "No data or header updates supplied" if ((data.nil? && $stdin.tty?) and headers.empty?)
151
158
  if headers['Content-Type'].nil?
152
159
  type = MIME::Types.type_for(self.name).first.to_s
153
160
  if type.empty?
@@ -156,6 +163,8 @@ module CloudFiles
156
163
  headers['Content-Type'] = type
157
164
  end
158
165
  end
166
+ # If we're taking data from standard input, send that IO object to cfreq
167
+ data = $stdin if (data.nil? && $stdin.tty? == false)
159
168
  response = self.container.connection.cfreq("PUT",@storagehost,"#{@storagepath}",headers,data)
160
169
  raise InvalidResponseException, "Invalid content-length header sent" if (response.code == "412")
161
170
  raise MisMatchedChecksumException, "Mismatched etag" if (response.code == "422")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rackspace-cloudfiles
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0.2
4
+ version: 1.3.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - H. Wade Minter, Rackspace Hosting
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-14 00:00:00 -07:00
12
+ date: 2009-05-16 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency