Module: Minestrone::Configuration::Actions::FileTransfer

Included in:
Minestrone::Configuration
Defined in:
lib/minestrone/configuration/actions/file_transfer.rb

Instance Method Summary collapse

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, options = {}, &block)
  transfer(:down, from, to, options, &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, options = {}, &block)
  download(remote_path, path, options, &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, options = {})
  opts = options.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, options = {}, &block)
  if dry_run
    return logger.debug "transfering: #{[direction, from, to] * ', '}"
  end

  execute_on_server do
    Transfer.process(direction, from, to, session, options.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, options = {}, &block)
  mode = options.delete(:mode)
  transfer(:up, from, to, options, &block)

  if mode
    mode = mode.is_a?(Numeric) ? mode.to_s(8) : mode.to_s
    run "chmod #{mode} #{to}", options
  end
end