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

- (Array) attributes



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

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

- (String) chef_type



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

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

- (String) cookbook_name



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

attribute :cookbook_name, String

- (Array) definitions



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

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

- (Array) files



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

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

- (String) json_class



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

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

- (Array) libraries



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

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

- (Hash) metadata



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

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

- (String) name



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

attribute :name, String

- (Array) providers



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

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

- (Array) recipes



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

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

- (Array) resources



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

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

- (Array) root_files



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

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

- (Array) templates



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

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

- (String) version



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

attribute :version, String

Class Method Details

+ (Object) get(name, version)



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

- (Object) do_delete



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

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

- (Object) do_post



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

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

- (Object) do_put



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

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

- (Boolean) new_record?

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