class Nanoc::LFTP::Deployer
Public Instance Methods
run()
click to toggle source
# File lib/nanoc/lftp/deployer.rb, line 12 def run # Get params src = source_path + '/' dst_host = config.fetch(:dst_host) do raise Nanoc::Errors::GenericTrivial, 'No dst_host found in deployment configuration' end dst_path = config.fetch(:dst_path) do raise Nanoc::Errors::GenericTrivial, 'No dst_path found in deployment configuration' end options = config.fetch(:options, []) # Build command options_esc = options.flatten.map { |e| esc(e) } lftp_cmd = [ 'mirror', '--reverse', *options_esc, esc(src), esc(dst_path) ].join(' ') + ' ; quit' cmd = [ 'lftp', '-e', lftp_cmd, dst_host ] # Run if dry_run warn 'Performing a dry-run; no actions will actually be performed' $stdout.puts(cmd) else run_shell_cmd(cmd) end end
Private Instance Methods
esc(s)
click to toggle source
# File lib/nanoc/lftp/deployer.rb, line 39 def esc(s) Shellwords.escape(s) end
run_shell_cmd(args)
click to toggle source
Runs the given shell command. It will raise an error if execution fails (results in a nonzero exit code).
# File lib/nanoc/lftp/deployer.rb, line 45 def run_shell_cmd(args) status = systemu(args, 'stdout' => $stdout, 'stderr' => $stderr) raise "command exited with a nonzero status code #{status.exitstatus} (command: #{args})" if !status.success? end