Class: Mina::Backend::Remote

Inherits:
Object
  • Object
show all
Includes:
Configuration::DSL
Defined in:
lib/mina/backend/remote.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Configuration::DSL

included

Constructor Details

#initialize(commands) ⇒ Remote

Returns a new instance of Remote


7
8
9
# File 'lib/mina/backend/remote.rb', line 7

def initialize(commands)
  @commands = commands
end

Instance Attribute Details

#commandsObject (readonly)

Returns the value of attribute commands


4
5
6
# File 'lib/mina/backend/remote.rb', line 4

def commands
  @commands
end

Instance Method Details

#prepareObject


11
12
13
14
15
16
17
18
19
20
21
# File 'lib/mina/backend/remote.rb', line 11

def prepare
  if fetch(:simulate)
    [
      '#!/usr/bin/env bash', "# Executing the following via '#{ssh}':",
      '#', commands, ' '
    ].join("\n")
  else
    command = Shellwords.escape(commands)
    [ssh, '--', command].join(' ')
  end
end

#sshObject


23
24
25
26
27
28
29
30
31
32
33
# File 'lib/mina/backend/remote.rb', line 23

def ssh
  ensure!(:domain)
  args = fetch(:domain)
  args = "#{fetch(:user)}@#{fetch(:domain)}" if set?(:user)
  args += " -i #{fetch(:identity_file)}" if set?(:identity_file)
  args += " -p #{fetch(:port)}" if set?(:port)
  args += ' -A' if set?(:forward_agent)
  args += " #{fetch(:ssh_options)}" if set?(:ssh_options)
  args += ' -tt'
  "ssh #{args}"
end