class Chef::ChefFS::FileSystem::ChefServer::CookbookFile
Attributes
Public Class Methods
Source
# File lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb, line 28 def initialize(name, parent, file) super(name, parent) @file = file end
Calls superclass method
Chef::ChefFS::FileSystem::BaseFSObject::new
Public Instance Methods
Source
# File lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb, line 35 def checksum file[:checksum] end
Source
# File lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb, line 54 def compare_to(other) other_value = nil if other.respond_to?(:checksum) other_checksum = other.checksum else begin other_value = other.read rescue Chef::ChefFS::FileSystem::NotFoundError return [ false, nil, :none ] end other_checksum = calc_checksum(other_value) end [ checksum == other_checksum, nil, other_value ] end
Source
# File lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb, line 39 def read tmpfile = rest.streaming_request(file[:url]) File.binread(tmpfile) rescue Timeout::Error => e raise Chef::ChefFS::FileSystem::OperationFailedError.new(:read, self, e, "Timeout reading #{file[:url]}: #{e}") rescue Net::HTTPClientException => e raise Chef::ChefFS::FileSystem::OperationFailedError.new(:read, self, e, "#{e.message} retrieving #{file[:url]}") rescue Errno::ENOENT raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!) end
Source
# File lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb, line 50 def rest parent.rest end
Private Instance Methods
Source
# File lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb, line 71 def calc_checksum(value) ::Digest::MD5.hexdigest(value) end