Class: Middleman::Deploy::Methods::Rsync

Inherits:
Base
  • Object
show all
Defined in:
lib/middleman-deploy/methods/rsync.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#options, #server_instance

Instance Method Summary collapse

Constructor Details

#initialize(server_instance, options = {}) ⇒ Rsync

Returns a new instance of Rsync.



8
9
10
11
12
13
14
15
16
17
# File 'lib/middleman-deploy/methods/rsync.rb', line 8

def initialize(server_instance, options={})
  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

Instance Attribute Details

#cleanObject (readonly)

Returns the value of attribute clean.



6
7
8
# File 'lib/middleman-deploy/methods/rsync.rb', line 6

def clean
  @clean
end

#flagsObject (readonly)

Returns the value of attribute flags.



6
7
8
# File 'lib/middleman-deploy/methods/rsync.rb', line 6

def flags
  @flags
end

#hostObject (readonly)

Returns the value of attribute host.



6
7
8
# File 'lib/middleman-deploy/methods/rsync.rb', line 6

def host
  @host
end

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/middleman-deploy/methods/rsync.rb', line 6

def path
  @path
end

#portObject (readonly)

Returns the value of attribute port.



6
7
8
# File 'lib/middleman-deploy/methods/rsync.rb', line 6

def port
  @port
end

#userObject (readonly)

Returns the value of attribute user.



6
7
8
# File 'lib/middleman-deploy/methods/rsync.rb', line 6

def user
  @user
end

Instance Method Details

#processObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/middleman-deploy/methods/rsync.rb', line 19

def process
  # Append "@" to user if provided.
  user      = "#{self.user}@" if self.user && !self.user.empty?

  dest_url  = "#{user}#{self.host}:#{self.path}"
  flags     = self.flags || '-avz'
  command   = "rsync #{flags} '-e ssh -p #{self.port}' #{self.server_instance.build_dir}/ #{dest_url}"

  if self.clean
    command += " --delete"
  end

  puts "## Deploying via rsync to #{dest_url} port=#{self.port}"
  run command
end