Parent

Class/Module Index [+]

Quicksearch

Chef::Sandbox

Constants

DESIGN_DOCUMENT

Attributes

checksums[RW]

list of checksum ids

couchdb[RW]
couchdb_id[RW]
couchdb_rev[RW]
create_time[RW]
guid[R]
is_completed[RW]
is_completed?[RW]
name[R]

Public Class Methods

cdb_list(inflate=false, couchdb=nil) click to toggle source
# File lib/chef/sandbox.rb, line 133
def self.cdb_list(inflate=false, couchdb=nil)
  rs = (couchdb || Chef::CouchDB.new).list("sandboxes", inflate)
  lookup = (inflate ? "value" : "key")
  rs["rows"].collect { |r| r[lookup] }            
end
cdb_load(guid, couchdb=nil) click to toggle source
# File lib/chef/sandbox.rb, line 139
def self.cdb_load(guid, couchdb=nil)
  # Probably want to look for a view here at some point
  (couchdb || Chef::CouchDB.new).load("sandbox", guid)
end
create_design_document(couchdb=nil) click to toggle source

Couchdb

# File lib/chef/sandbox.rb, line 129
def self.create_design_document(couchdb=nil)
  (couchdb || Chef::CouchDB.new).create_design_document("sandboxes", DESIGN_DOCUMENT)
end
json_create(o) click to toggle source
# File lib/chef/sandbox.rb, line 108
def self.json_create(o)
  sandbox = new(o['guid'])
  sandbox.checksums = o['checksums']
  sandbox.create_time = o['create_time']
  sandbox.is_completed = o['is_completed']
  if o.has_key?('_rev')
    sandbox.couchdb_rev = o["_rev"]
    o.delete("_rev")
  end
  if o.has_key?("_id")
    sandbox.couchdb_id = o["_id"]
    #sandbox.index_id = sandbox.couchdb_id
    o.delete("_id")
  end
  sandbox
end
new(guid=nil, couchdb=nil) click to toggle source

Creates a new Chef::Sandbox object.

Returns

object<Chef::Sandbox>

Duh. :)

# File lib/chef/sandbox.rb, line 81
def initialize(guid=nil, couchdb=nil)
  @guid = guid || UUIDTools::UUID.random_create.to_s.gsub(/\-/,'').downcase
  @is_completed = false
  @create_time = Time.now.iso8601
  @checksums = Array.new
end

Public Instance Methods

cdb_destroy() click to toggle source
# File lib/chef/sandbox.rb, line 144
def cdb_destroy
  (couchdb || Chef::CouchDB.new).delete("sandbox", guid, @couchdb_rev)
end
cdb_save(couchdb=nil) click to toggle source
# File lib/chef/sandbox.rb, line 148
def cdb_save(couchdb=nil)
  @couchdb_rev = (couchdb || Chef::CouchDB.new).store("sandbox", guid, self)["rev"]
end
include?(checksum) click to toggle source
# File lib/chef/sandbox.rb, line 88
def include?(checksum)
  @checksums.include?(checksum)
end
Also aliased as: member?
member?(checksum) click to toggle source
Alias for: include?
to_json(*a) click to toggle source
# File lib/chef/sandbox.rb, line 94
def to_json(*a)
  result = {
    :guid => guid,
    :name => name,   # same as guid, used for id_map
    :checksums => checksums,
    :create_time => create_time,
    :is_completed => is_completed,
    :json_class => self.class.name,
    :chef_type => 'sandbox'
  }
  result["_rev"] = @couchdb_rev if @couchdb_rev
  result.to_json(*a)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.