Module: Capistrano::Configuration::Actions::FileTransfer

Included in:
Capistrano::Configuration
Defined in:
lib/capistrano/configuration/actions/file_transfer.rb

Instance Method Summary collapse

Instance Method Details

#get(remote_path, path, options = {}) ⇒ Object

Get file remote_path from FIRST server targetted by the current task and transfer it to local machine as path.

get “#deploy_to/current/log/production.log”, “log/production.log.web”



22
23
24
25
26
27
28
29
30
# File 'lib/capistrano/configuration/actions/file_transfer.rb', line 22

def get(remote_path, path, options = {})
  execute_on_servers(options.merge(:once => true)) do |servers|
    logger.info "downloading `#{servers.first.host}:#{remote_path}' to `#{path}'"
    sftp = sessions[servers.first].sftp
    sftp.connect unless sftp.state == :open
    sftp.get_file remote_path, path
    logger.debug "download finished" 
  end
end

#put(data, path, options = {}) ⇒ Object

Store the given data at the given location on all servers targetted by the current task. If :mode is specified it is used to set the mode on the file.



11
12
13
14
15
16
# File 'lib/capistrano/configuration/actions/file_transfer.rb', line 11

def put(data, path, options={})
  execute_on_servers(options) do |servers|
    targets = servers.map { |s| sessions[s] }
    Upload.process(targets, path, :data => data, :mode => options[:mode], :logger => logger)
  end
end