Class: Chef::ChefFS::FileSystem::CookbookFile
Instance Attribute Summary collapse
Attributes inherited from BaseFSObject
#name, #parent, #path
Instance Method Summary
collapse
#can_have_child?, #child, #dir?, #exists?, #path_for_printing, #root
Constructor Details
#initialize(name, parent, file) ⇒ CookbookFile
Returns a new instance of CookbookFile.
26
27
28
29
|
# File 'lib/chef/chef_fs/file_system/cookbook_file.rb', line 26
def initialize(name, parent, file)
super(name, parent)
@file = file
end
|
Instance Attribute Details
Returns the value of attribute file.
31
32
33
|
# File 'lib/chef/chef_fs/file_system/cookbook_file.rb', line 31
def file
@file
end
|
Instance Method Details
33
34
35
|
# File 'lib/chef/chef_fs/file_system/cookbook_file.rb', line 33
def checksum
file[:checksum]
end
|
#compare_to(other) ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/chef/chef_fs/file_system/cookbook_file.rb', line 51
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
|
37
38
39
40
41
42
43
44
45
|
# File 'lib/chef/chef_fs/file_system/cookbook_file.rb', line 37
def read
old_sign_on_redirect = rest.sign_on_redirect
rest.sign_on_redirect = false
begin
rest.get_rest(file[:url])
ensure
rest.sign_on_redirect = old_sign_on_redirect
end
end
|
47
48
49
|
# File 'lib/chef/chef_fs/file_system/cookbook_file.rb', line 47
def rest
parent.rest
end
|