2014-01-16 15:25:40 +01:00
|
|
|
module Middleman
|
|
|
|
module Deploy
|
|
|
|
module Methods
|
|
|
|
class Rsync < Base
|
|
|
|
attr_reader :clean, :flags, :host, :path, :port, :user
|
|
|
|
|
2014-05-29 11:57:30 +02:00
|
|
|
def initialize(server_instance, options = {})
|
2014-01-16 15:25:40 +01:00
|
|
|
super(server_instance, options)
|
|
|
|
|
|
|
|
@clean = self.options.clean
|
|
|
|
@flags = self.options.flags
|
|
|
|
@host = self.options.host
|
|
|
|
@path = self.options.path
|
|
|
|
@port = self.options.port
|
|
|
|
@user = self.options.user
|
|
|
|
end
|
|
|
|
|
|
|
|
def process
|
|
|
|
# Append "@" to user if provided.
|
2015-08-16 20:06:10 +02:00
|
|
|
user = "#{self.user}@" if user && !user.empty?
|
2014-01-16 15:25:40 +01:00
|
|
|
|
2015-08-16 20:06:10 +02:00
|
|
|
dest_url = "#{user}#{host}:#{path}"
|
2014-02-23 15:26:27 +01:00
|
|
|
flags = self.flags || '-avz'
|
2015-08-16 20:06:10 +02:00
|
|
|
command = "rsync #{flags} '-e ssh -p #{port}' #{build_dir}/ #{dest_url}"
|
2014-01-16 15:25:40 +01:00
|
|
|
|
2015-08-16 20:06:10 +02:00
|
|
|
command += ' --delete' if clean
|
2014-01-16 15:25:40 +01:00
|
|
|
|
2015-08-16 20:06:10 +02:00
|
|
|
puts "## Deploying via rsync to #{dest_url} port=#{port}"
|
2014-02-26 12:04:08 +01:00
|
|
|
exec command
|
2014-01-16 15:25:40 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|