Class: Chef::Provider::RemoteFile::NetworkFile

Inherits:
Object
  • Object
show all
Defined in:
lib/chef/provider/remote_file/network_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, new_resource, current_resource) ⇒ NetworkFile

Returns a new instance of NetworkFile.



30
31
32
33
# File 'lib/chef/provider/remote_file/network_file.rb', line 30

def initialize(source, new_resource, current_resource)
  @new_resource = new_resource
  @source = source
end

Instance Attribute Details

#new_resourceObject (readonly)

Returns the value of attribute new_resource.



28
29
30
# File 'lib/chef/provider/remote_file/network_file.rb', line 28

def new_resource
  @new_resource
end

Instance Method Details

#fetchObject

Fetches the file on a network share, returning a Tempfile-like File handle windows only



37
38
39
40
41
42
43
# File 'lib/chef/provider/remote_file/network_file.rb', line 37

def fetch
  tempfile = Chef::FileContentManagement::Tempfile.new(new_resource).tempfile
  Chef::Log.debug("#{new_resource} staging #{@source} to #{tempfile.path}")
  FileUtils.cp(@source, tempfile.path)
  tempfile.close if tempfile
  tempfile
end