Class: Stove::Uploader

Inherits:
Object
  • Object
show all
Includes:
HTTMultiParty
Defined in:
lib/stove/uploader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cookbook) ⇒ Uploader

Create a new uploader instance for the given cookbook.

Parameters:



19
20
21
# File 'lib/stove/uploader.rb', line 19

def initialize(cookbook)
  @cookbook = cookbook
end

Instance Attribute Details

#cookbookStove::Cookbook (readonly)

The cookbook associated with this uploader

Returns:



13
14
15
# File 'lib/stove/uploader.rb', line 13

def cookbook
  @cookbook
end

Instance Method Details

#upload!Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/stove/uploader.rb', line 23

def upload!
  response = self.class.post(upload_url, {
    :headers => headers,
    :query   => {
      :tarball  => File.new(cookbook.tarball),
      :cookbook => { category: cookbook.category }.to_json,
    },
  })

  if response.success?
    Stove.formatter.upload(cookbook)
  else
    raise Stove::UploadError.new(response)
  end
end