class Chef::Provider::RemoteFile::LocalFile

Attributes

new_resource[R]
uri[R]

Public Class Methods

new(uri, new_resource, current_resource) click to toggle source
# 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

Public Instance Methods

fetch() click to toggle source

Fetches the file at uri, returning a Tempfile-like File handle

# File lib/chef/provider/remote_file/local_file.rb, line 49
def fetch
  tempfile = Chef::FileContentManagement::Tempfile.new(new_resource).tempfile
  Chef::Log.trace("#{new_resource} staging #{source_path} to #{tempfile.path}")
  FileUtils.cp(source_path, tempfile.path)
  tempfile.close if tempfile
  tempfile
end
fix_windows_path(path) click to toggle source

CHEF-4472: Remove the leading slash from windows paths that we receive from a file:// URI

# File lib/chef/provider/remote_file/local_file.rb, line 37
def fix_windows_path(path)
  path.gsub(/^\/([a-zA-Z]:)/, '\1')
end
source_path() click to toggle source
# File lib/chef/provider/remote_file/local_file.rb, line 41
def source_path
  @source_path ||= begin
    path = URI.unescape(uri.path)
    Chef::Platform.windows? ? fix_windows_path(path) : path
  end
end