Module: Minestrone::Configuration::Actions::FileTransfer
- Included in:
- Minestrone::Configuration
- Defined in:
- lib/minestrone/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 the configured server and transfer it to local machine as path.
-
#put(data, path, options = {}) ⇒ Object
Store the given data at the given location on the configured server.
- #transfer(direction, from, to, options = {}, &block) ⇒ Object
- #upload(from, to, options = {}, &block) ⇒ Object
Instance Method Details
#download(from, to, options = {}, &block) ⇒ Object
37 38 39 |
# File 'lib/minestrone/configuration/actions/file_transfer.rb', line 37 def download(from, to, = {}, &block) transfer(:down, from, to, , &block) end |
#get(remote_path, path, options = {}, &block) ⇒ Object
Get file remote_path from the configured server and transfer it to local machine as path.
get “#deploy_to/current/log/production.log”, “log/production.log.web”
23 24 25 |
# File 'lib/minestrone/configuration/actions/file_transfer.rb', line 23 def get(remote_path, path, = {}, &block) download(remote_path, path, , &block) end |
#put(data, path, options = {}) ⇒ Object
Store the given data at the given location on the configured server. If :mode is specified it is used to set the mode on the file.
13 14 15 16 |
# File 'lib/minestrone/configuration/actions/file_transfer.rb', line 13 def put(data, path, = {}) opts = .dup upload(StringIO.new(data), path, opts) end |
#transfer(direction, from, to, options = {}, &block) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/minestrone/configuration/actions/file_transfer.rb', line 41 def transfer(direction, from, to, = {}, &block) if dry_run return logger.debug "transfering: #{[direction, from, to] * ', '}" end execute_on_server do Transfer.process(direction, from, to, session, .merge(:logger => logger), &block) end end |
#upload(from, to, options = {}, &block) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/minestrone/configuration/actions/file_transfer.rb', line 27 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 |