def self.sync_from_disk_to_couchdb
Dir[File.join(Chef::Config[:role_path], "*.json")].each do |role_file|
short_name = File.basename(role_file, ".json")
Chef::Log.warn("Loading #{short_name}")
r = Chef::Role.from_disk(short_name, "json")
begin
couch_role = Chef::Role.cdb_load(short_name)
r.couchdb_rev = couch_role.couchdb_rev
Chef::Log.debug("Replacing role #{short_name} with data from #{role_file}")
rescue Chef::Exceptions::CouchDBNotFound
Chef::Log.debug("Creating role #{short_name} with data from #{role_file}")
end
r.cdb_save
end
end