Module: Capistrano::Configuration::Actions::FileTransfer
- Included in:
- Capistrano::Configuration
- Defined in:
- lib/capistrano/configuration/actions/file_transfer.rb
Instance Method Summary collapse
- #download(from, to, options = {}, &block) ⇒ Object
-
#get(remote_path, path, options = {}, &block) ⇒ Object
Get file remote_path from FIRST server targeted by the current task and transfer it to local machine as path.
-
#put(data, path, options = {}) ⇒ Object
Store the given data at the given location on all servers targetted by the current task.
- #transfer(direction, from, to, options = {}, &block) ⇒ Object
- #upload(from, to, options = {}, &block) ⇒ Object
Instance Method Details
#download(from, to, options = {}, &block) ⇒ Object
33 34 35 |
# File 'lib/capistrano/configuration/actions/file_transfer.rb', line 33 def download(from, to, ={}, &block) transfer(:down, from, to, , &block) end |
#get(remote_path, path, options = {}, &block) ⇒ Object
Get file remote_path from FIRST server targeted by the current task and transfer it to local machine as path.
get “#deploy_to/current/log/production.log”, “log/production.log.web”
20 21 22 |
# File 'lib/capistrano/configuration/actions/file_transfer.rb', line 20 def get(remote_path, path, ={}, &block) download(remote_path, path, .merge(:once => true), &block) 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 |
# File 'lib/capistrano/configuration/actions/file_transfer.rb', line 11 def put(data, path, ={}) opts = .dup upload(StringIO.new(data), path, opts) end |
#transfer(direction, from, to, options = {}, &block) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/capistrano/configuration/actions/file_transfer.rb', line 37 def transfer(direction, from, to, ={}, &block) if dry_run return logger.debug "transfering: #{[direction, from, to] * ', '}" end execute_on_servers() do |servers| targets = servers.map { |s| sessions[s] } Transfer.process(direction, from, to, targets, .merge(:logger => logger), &block) end end |
#upload(from, to, options = {}, &block) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/capistrano/configuration/actions/file_transfer.rb', line 24 def upload(from, to, ={}, &block) mode = .delete(:mode) transfer(:up, from, to, , &block) if mode mode = mode.is_a?(Numeric) ? mode.to_s(8) : mode.to_s run "chmod #{mode} #{to}", end end |