Sha256: 6fa725789d0ce91c1f6bd34e2561d23bb9fac12c4c2c58bc8d189d5ce7e30ba0

Contents?: true

Size: 937 Bytes

Versions: 18

Compression:

Stored size: 937 Bytes

Contents

module Mina
  module Backend
    class Remote
      attr_reader :commands
      include Configuration::DSL

      def initialize(commands)
        @commands = commands
      end

      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

      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

    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
mina-1.2.4 lib/mina/backend/remote.rb
mina-1.2.3 lib/mina/backend/remote.rb
mina-1.2.2 lib/mina/backend/remote.rb
mina-1.2.1 lib/mina/backend/remote.rb
mina-1.2.0 lib/mina/backend/remote.rb
mina-1.1.1 lib/mina/backend/remote.rb
mina-1.1.0 lib/mina/backend/remote.rb
mina-1.0.7 lib/mina/backend/remote.rb
mina-1.0.6 lib/mina/backend/remote.rb
mina-1.0.5 lib/mina/backend/remote.rb
mina-1.0.4 lib/mina/backend/remote.rb
mina-1.0.3 lib/mina/backend/remote.rb
mina-1.0.2 lib/mina/backend/remote.rb
mina-1.0.0 lib/mina/backend/remote.rb
mina-1.0.0.rc2 lib/mina/backend/remote.rb
mina-1.0.0.beta5 lib/mina/backend/remote.rb
mina-1.0.0.beta4 lib/mina/backend/remote.rb
mina-1.0.0.beta3 lib/mina/backend/remote.rb