# 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
# 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
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
# 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
Creates a new Chef::Sandbox object.
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
# File lib/chef/sandbox.rb, line 144 def cdb_destroy (couchdb || Chef::CouchDB.new).delete("sandbox", guid, @couchdb_rev) end
# File lib/chef/sandbox.rb, line 148 def cdb_save(couchdb=nil) @couchdb_rev = (couchdb || Chef::CouchDB.new).store("sandbox", guid, self)["rev"] end
# File lib/chef/sandbox.rb, line 88 def include?(checksum) @checksums.include?(checksum) end
# 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
Generated with the Darkfish Rdoc Generator 2.