class Chef::FileContentManagement::Tempfile
Attributes
new_resource[R]
Public Class Methods
new(new_resource)
click to toggle source
# File lib/chef/file_content_management/tempfile.rb, line 27 def initialize(new_resource) @new_resource = new_resource end
Public Instance Methods
tempfile()
click to toggle source
# File lib/chef/file_content_management/tempfile.rb, line 31 def tempfile @tempfile ||= tempfile_open end
Private Instance Methods
tempfile_basename()
click to toggle source
These are important for windows to get permissions right, and may be useful for SELinux and other ACL approaches. Please use them as the arguments to ::new consistently.
# File lib/chef/file_content_management/tempfile.rb, line 50 def tempfile_basename basename = ::File.basename(@new_resource.name) basename.insert 0, "." unless Chef::Platform.windows? # dotfile if we're not on windows basename end
tempfile_dirname()
click to toggle source
# File lib/chef/file_content_management/tempfile.rb, line 56 def tempfile_dirname Chef::Config[:file_staging_uses_destdir] ? ::File.dirname(@new_resource.path) : Dir::tmpdir end
tempfile_open()
click to toggle source
# File lib/chef/file_content_management/tempfile.rb, line 37 def tempfile_open tf = ::Tempfile.open(tempfile_basename, tempfile_dirname) # We always process the tempfile in binmode so that we # preserve the line endings of the content. tf.binmode tf end