Class: Roger::Release::Finalizers::Rsync

Inherits:
Base
  • Object
show all
Defined in:
lib/roger/release/finalizers/rsync.rb

Overview

Finalizes the release by uploading your mockup with rsync to a remote server

See Also:

  • for options

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Rsync

Returns a new instance of Rsync.

Parameters:

  • Hash

    options The options

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • String (Object)

    :rsync The Rsync command to run (default is “rsync”)

  • String (Object)

    :remote_path The remote path to upload to

  • String (Object)

    :host The remote host to upload to

  • String (Object)

    :username The remote username to upload to

  • Boolean (Object)

    :ask Prompt the user before uploading (default is true)



17
18
19
20
21
22
23
24
25
# File 'lib/roger/release/finalizers/rsync.rb', line 17

def initialize(options = {})
  @options = {
    rsync: "rsync",
    remote_path: "",
    host: nil,
    username: nil,
    ask: true
  }.update(options)
end

Instance Method Details

#call(release, options = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/roger/release/finalizers/rsync.rb', line 27

def call(release, options = {})
  options = @options.dup.update(options)

  # Validate options
  validate_options!(release, options)

  return unless prompt_for_upload(options)

  check_rsync_command(options[:rsync])

  local_path = release.build_path.to_s
  remote_path = options[:remote_path]

  local_path += "/" unless local_path =~ %r{/\Z}
  remote_path += "/" unless remote_path =~ %r{/\Z}

  release.log(self, "Starting upload of #{(release.build_path + '*')} to #{options[:host]}")
  rsync(options[:rsync], local_path, remote_path, options)
end