Class: Chef::Provider::RemoteFile::LocalFile
- Defined in:
- lib/chef/provider/remote_file/local_file.rb
Instance Attribute Summary collapse
-
#new_resource ⇒ Object
readonly
Returns the value of attribute new_resource.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#fetch ⇒ Object
Fetches the file at uri, returning a Tempfile-like File handle.
-
#initialize(uri, new_resource, current_resource) ⇒ LocalFile
constructor
A new instance of LocalFile.
Constructor Details
#initialize(uri, new_resource, current_resource) ⇒ LocalFile
Returns a new instance of LocalFile.
31 32 33 34 |
# File 'lib/chef/provider/remote_file/local_file.rb', line 31 def initialize(uri, new_resource, current_resource) @new_resource = new_resource @uri = uri end |
Instance Attribute Details
#new_resource ⇒ Object (readonly)
Returns the value of attribute new_resource.
29 30 31 |
# File 'lib/chef/provider/remote_file/local_file.rb', line 29 def new_resource @new_resource end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
28 29 30 |
# File 'lib/chef/provider/remote_file/local_file.rb', line 28 def uri @uri end |
Instance Method Details
#fetch ⇒ Object
Fetches the file at uri, returning a Tempfile-like File handle
37 38 39 40 41 42 43 |
# File 'lib/chef/provider/remote_file/local_file.rb', line 37 def fetch tempfile = Chef::FileContentManagement::Tempfile.new(new_resource).tempfile Chef::Log.debug("#{new_resource} staging #{uri.path} to #{tempfile.path}") FileUtils.cp(uri.path, tempfile.path) tempfile.close if tempfile tempfile end |