Class: Chef::ChefFS::FileSystem::ChefServer::CookbookFile
- Inherits:
-
BaseFSObject
- Object
- BaseFSObject
- Chef::ChefFS::FileSystem::ChefServer::CookbookFile
show all
- Defined in:
- lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb
Instance Attribute Summary collapse
Attributes inherited from BaseFSObject
#name, #parent, #path
Instance Method Summary
collapse
#can_have_child?, #chef_object, #child, #children, #create_child, #delete, #dir?, #exists?, #path_for_printing, #root, #write
Constructor Details
#initialize(name, parent, file) ⇒ CookbookFile
Returns a new instance of CookbookFile.
28
29
30
31
|
# 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
|
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
33
34
35
|
# File 'lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb', line 33
def file
@file
end
|
Instance Method Details
#checksum ⇒ Object
35
36
37
|
# File 'lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb', line 35
def checksum
file[:checksum]
end
|
#compare_to(other) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb', line 60
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
|
#read ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb', line 39
def read
begin
tmpfile = rest.streaming_request(file[:url])
rescue Timeout::Error => e
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:read, self, e, "Timeout reading #{file[:url]}: #{e}")
rescue Net::HTTPServerException => e
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:read, self, e, "#{e.message} retrieving #{file[:url]}")
end
begin
tmpfile.open
tmpfile.read
ensure
tmpfile.close!
end
end
|
#rest ⇒ Object
56
57
58
|
# File 'lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb', line 56
def rest
parent.rest
end
|