Implement `file_write' action
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
require 'producer/core/action'
|
||||
require 'producer/core/actions/echo'
|
||||
require 'producer/core/actions/shell_command'
|
||||
require 'producer/core/actions/file_writer'
|
||||
|
||||
# condition tests (need to be defined before the condition DSL)
|
||||
require 'producer/core/test'
|
||||
|
19
lib/producer/core/actions/file_writer.rb
Normal file
19
lib/producer/core/actions/file_writer.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
module Producer
|
||||
module Core
|
||||
module Actions
|
||||
class FileWriter < Action
|
||||
def apply
|
||||
env.remote.fs.file_write path, content
|
||||
end
|
||||
|
||||
def path
|
||||
arguments[0]
|
||||
end
|
||||
|
||||
def content
|
||||
arguments[1]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -17,6 +17,12 @@ module Producer
|
||||
rescue Net::SFTP::StatusException
|
||||
false
|
||||
end
|
||||
|
||||
def file_write(path, content)
|
||||
sftp.file.open path, 'w' do |f|
|
||||
f.write content
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -19,6 +19,8 @@ module Producer
|
||||
define_action :echo, Actions::Echo
|
||||
define_action :sh, Actions::ShellCommand
|
||||
|
||||
define_action :file_write, Actions::FileWriter
|
||||
|
||||
attr_accessor :actions
|
||||
|
||||
def initialize(&block)
|
||||
|
Reference in New Issue
Block a user