summaryrefslogtreecommitdiff
path: root/lib/chef/cookbook_site_streaming_uploader.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/cookbook_site_streaming_uploader.rb')
-rw-r--r--lib/chef/cookbook_site_streaming_uploader.rb18
1 files changed, 7 insertions, 11 deletions
diff --git a/lib/chef/cookbook_site_streaming_uploader.rb b/lib/chef/cookbook_site_streaming_uploader.rb
index 6e669f24ba..71ce3f86c2 100644
--- a/lib/chef/cookbook_site_streaming_uploader.rb
+++ b/lib/chef/cookbook_site_streaming_uploader.rb
@@ -30,11 +30,9 @@ class Chef
#
# inspired by http://stanislavvitvitskiy.blogspot.com/2008/12/multipart-post-in-ruby.html
class CookbookSiteStreamingUploader
-
DefaultHeaders = { "accept" => "application/json", "x-chef-version" => ::Chef::VERSION }
class << self
-
def create_build_dir(cookbook)
tmp_cookbook_path = Tempfile.new("chef-#{cookbook.name}-build")
tmp_cookbook_path.close
@@ -114,14 +112,14 @@ class Chef
# TODO: tim: 2009-12-28: It'd be nice to remove this special case, and
# always hash the entire request body. In the file case it would just be
# expanded multipart text - the entire body of the POST.
- content_body = parts.inject("") { |result,part| result + part.read(0, part.size) }
+ content_body = parts.inject("") { |result, part| result + part.read(0, part.size) }
content_file.rewind if content_file # we consumed the file for the above operation, so rewind it.
signing_options = {
- :http_method=>http_verb,
- :path=>url.path,
- :user_id=>user_id,
- :timestamp=>timestamp}
+ :http_method => http_verb,
+ :path => url.path,
+ :user_id => user_id,
+ :timestamp => timestamp }
(content_file && signing_options[:file] = content_file) || (signing_options[:body] = (content_body || ""))
headers.merge!(Mixlib::Authentication::SignedHeaderAuth.signing_object(signing_options).sign(secret_key))
@@ -129,7 +127,7 @@ class Chef
content_file.rewind if content_file
# net/http doesn't like symbols for header keys, so we'll to_s each one just in case
- headers = DefaultHeaders.merge(Hash[*headers.map{ |k,v| [k.to_s, v] }.flatten])
+ headers = DefaultHeaders.merge(Hash[*headers.map { |k, v| [k.to_s, v] }.flatten])
req = case http_verb
when :put
@@ -160,7 +158,6 @@ class Chef
end
res
end
-
end
class StreamPart
@@ -201,7 +198,7 @@ class Chef
end
def size
- @parts.inject(0) {|size, part| size + part.size}
+ @parts.inject(0) { |size, part| size + part.size }
end
def read(how_much, dst_buf = nil)
@@ -239,6 +236,5 @@ class Chef
dst_buf ? dst_buf.replace(result || "") : result
end
end
-
end
end