Class: Spice::CookbookVersion

Inherits:
Object
  • Object
show all
Extended by:
Persistence
Includes:
Persistence, Toy::Store
Defined in:
lib/spice/cookbook_version.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Persistence

all, connection, endpoint, get, included

Instance Attribute Details

#attributesArray



17
# File 'lib/spice/cookbook_version.rb', line 17

attribute :attributes, Array, :default => []

#chef_typeString



30
# File 'lib/spice/cookbook_version.rb', line 30

attribute :chef_type, String, :default => "cookbook_version"

#cookbook_nameString



26
# File 'lib/spice/cookbook_version.rb', line 26

attribute :cookbook_name, String

#definitionsArray



16
# File 'lib/spice/cookbook_version.rb', line 16

attribute :definitions, Array, :default => []

#filesArray



18
# File 'lib/spice/cookbook_version.rb', line 18

attribute :files, Array, :default => []

#json_classString



25
# File 'lib/spice/cookbook_version.rb', line 25

attribute :json_class, String, :default => "Chef::CookbookVersion"

#librariesArray



21
# File 'lib/spice/cookbook_version.rb', line 21

attribute :libraries, Array, :default => []

#metadataHash



20
# File 'lib/spice/cookbook_version.rb', line 20

attribute :metadata, Hash, :default => {}

#nameString



14
# File 'lib/spice/cookbook_version.rb', line 14

attribute :name, String

#providersArray



19
# File 'lib/spice/cookbook_version.rb', line 19

attribute :providers, Array, :default => []

#recipesArray



28
# File 'lib/spice/cookbook_version.rb', line 28

attribute :recipes, Array, :default => []

#resourcesArray



23
# File 'lib/spice/cookbook_version.rb', line 23

attribute :resources, Array, :default => []

#root_filesArray



29
# File 'lib/spice/cookbook_version.rb', line 29

attribute :root_files, Array, :default => []

#templatesArray



22
# File 'lib/spice/cookbook_version.rb', line 22

attribute :templates, Array, :default => []

#versionString



15
# File 'lib/spice/cookbook_version.rb', line 15

attribute :version, String

Class Method Details

.get(name, version) ⇒ Object



46
47
48
# File 'lib/spice/cookbook_version.rb', line 46

def self.get(name, version)
  connection.cookbook_version(name, version)
end

Instance Method Details

#do_deleteObject



42
43
44
# File 'lib/spice/cookbook_version.rb', line 42

def do_delete
  connection.delete("/cookbooks/#{cookbook_name}/#{version}")
end

#do_postObject



34
35
36
# File 'lib/spice/cookbook_version.rb', line 34

def do_post
  connection.put("/cookbooks/#{cookbook_name}/#{version}", attributes)
end

#do_putObject



38
39
40
# File 'lib/spice/cookbook_version.rb', line 38

def do_put
  connection.put("/cookbooks/#{cookbook_name}/#{version}", attributes)
end

#new_record?Boolean

Check if the cookbook version exists on the Chef server



51
52
53
54
55
56
57
58
# File 'lib/spice/cookbook_version.rb', line 51

def new_record?
  begin
    connection.get("/cookbooks/#{name}/#{version}")
    return false
  rescue Spice::Error::NotFound
    return true
  end
end