Skip to content

Instantly share code, notes, and snippets.

@jkeiser
Created October 16, 2015 17:53
Show Gist options
  • Save jkeiser/e5aed3fde5aa20294bed to your computer and use it in GitHub Desktop.
Save jkeiser/e5aed3fde5aa20294bed to your computer and use it in GitHub Desktop.
# resources/super_file
property :path, String, name_property: true, coerce: proc { }, default: lazy { }
property :mode, Integer, default: '755', coerce: proc { |v| v.to_i(8) }
property :content, String
load_current_value do
current_value_does_not_exist! if !File.exist?(path)
mode File.stat(path).mode
content IO.read(path)
end
action :create do
converge_if_changed do
File.open(path, "w") { |f| f.write(content) }
File.chmod(path, mode)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment