class SousChef::Resource::File
Public Instance Methods
content(content=nil)
click to toggle source
# File lib/sous_chef/resource/file.rb, line 4 def content(content=nil) set_or_return(:content, content && content.to_s) end
Protected Instance Methods
create()
click to toggle source
# File lib/sous_chef/resource/file.rb, line 13 def create not_if file_exist_command unless forced? command create_file_command end
create_file_command()
click to toggle source
# File lib/sous_chef/resource/file.rb, line 35 def create_file_command if content lines = [] lines << "cat <<'#{heredoc}' > #{escape_path(path)}" lines << escaped_content lines << heredoc lines.join("\n") else %{touch #{escape_path(path)}} end end
delete()
click to toggle source
# File lib/sous_chef/resource/file.rb, line 18 def delete only_if file_exist_command unless forced? command "rm #{'-f ' if forced?}#{escape_path(path)}" end
escaped_content()
click to toggle source
# File lib/sous_chef/resource/file.rb, line 9 def escaped_content content end
file_exist_command()
click to toggle source
# File lib/sous_chef/resource/file.rb, line 23 def file_exist_command %{test -e #{escape_path(path)}} end
heredoc()
click to toggle source
# File lib/sous_chef/resource/file.rb, line 27 def heredoc @heredoc ||= begin candidate = "SousChefHeredoc" candidate += "1" while content.include?(candidate) candidate end end