Support `file_write' status attributes

This commit is contained in:
Thibault Jouan
2014-10-08 22:30:12 +00:00
parent a84b34b7ca
commit c4006416e4
5 changed files with 34 additions and 61 deletions

View File

@@ -2,29 +2,20 @@ module Producer
module Core
module Actions
class FileWriter < Action
def initialize(env, *args, **options)
super
@path, @content = arguments
@options[:permissions] = @options.delete :mode if @options.key? :mode
@options[:owner] = @options.delete :user if @options.key? :user
end
def name
'file_write'
end
def apply
case arguments.size
when 2
fs.file_write path, content
when 3
fs.file_write path, content, mode
end
end
def path
arguments[0]
end
def content
arguments[1]
end
def mode
arguments[2]
fs.file_write @path, @content
fs.setstat @path, @options unless @options.empty?
end
end
end