Method: Chef::FileCache.load
- Defined in:
- lib/chef/file_cache.rb
.load(path, read = true) ⇒ Object
Read a file from the File Cache
Parameters
- path<String>
-
The path to the file you want to load - should
be relative to file_cache_path
- read<True/False>
-
Whether to return the file contents, or the path.
Defaults to true.
Returns
- String
-
A string with the file contents, or the path to the file.
Raises
- Chef::Exceptions::FileNotFound
-
If it cannot find the file in the cache
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/chef/file_cache.rb', line 104 def load(path, read=true) validate( { :path => path }, { :path => { :kind_of => String } } ) cache_path = create_cache_path(path, false) raise Chef::Exceptions::FileNotFound, "Cannot find #{cache_path} for #{path}!" unless File.exists?(cache_path) if read File.read(cache_path) else cache_path end end |