Accept mode as argument in `file_write' action

This commit is contained in:
Thibault Jouan
2014-04-24 23:46:43 +00:00
parent 47412d8bce
commit 5cb6296057
6 changed files with 64 additions and 5 deletions

View File

@@ -3,7 +3,12 @@ module Producer
module Actions
class FileWriter < Action
def apply
fs.file_write path, content
case arguments.size
when 2
fs.file_write path, content
when 3
fs.file_write path, content, mode
end
end
def path
@@ -13,6 +18,10 @@ module Producer
def content
arguments[1]
end
def mode
arguments[2]
end
end
end
end

View File

@@ -30,8 +30,8 @@ module Producer
nil
end
def file_write(path, content)
sftp.file.open path, 'w' do |f|
def file_write(path, content, mode = nil)
sftp.file.open path, 'w', mode do |f|
f.write content
end
end