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

Returns the attributes attribute

Returns:

  • (Array)

    the attributes attribute



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

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

- (String) chef_type

Returns the chef_type attribute

Returns:

  • (String)

    the chef_type attribute



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

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

- (String) cookbook_name

Returns the cookbook_name attribute

Returns:

  • (String)

    the cookbook_name attribute



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

attribute :cookbook_name, String

- (Array) definitions

Returns the definitions attribute

Returns:

  • (Array)

    the definitions attribute



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

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

- (Array) files

Returns the files attribute

Returns:

  • (Array)

    the files attribute



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

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

- (String) json_class

Returns the json_class attribute

Returns:

  • (String)

    the json_class attribute



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

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

- (Array) libraries

Returns the libraries attribute

Returns:

  • (Array)

    the libraries attribute



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

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

- (Hash) metadata

Returns the metadata attribute

Returns:

  • (Hash)

    the metadata attribute



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

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

- (String) name

Returns the name attribute

Returns:

  • (String)

    the name attribute



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

attribute :name, String

- (Array) providers

Returns the providers attribute

Returns:

  • (Array)

    the providers attribute



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

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

- (Array) recipes

Returns the recipes attribute

Returns:

  • (Array)

    the recipes attribute



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

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

- (Array) resources

Returns the resources attribute

Returns:

  • (Array)

    the resources attribute



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

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

- (Array) root_files

Returns the root_files attribute

Returns:

  • (Array)

    the root_files attribute



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

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

- (Array) templates

Returns the templates attribute

Returns:

  • (Array)

    the templates attribute



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

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

- (String) version

Returns the version attribute

Returns:

  • (String)

    the version attribute



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

Returns:

  • (Boolean)


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