Sha256: bbef7b7ff02bef55308b166086be299daff86ac938b6d9ff38421a18e7184ea6

Contents?: true

Size: 872 Bytes

Versions: 3

Compression:

Stored size: 872 Bytes

Contents

require 'sshkit/runners/abstract'

#Patch to support backend option
# Sent PR https://github.com/capistrano/sshkit/pull/117, except constantinize
module SSHKit

  module Runner

    class Abstract

      attr_reader :hosts, :options, :block

      def initialize(hosts, options = nil, &block)
        @hosts   = Array(hosts)
        @options = options || {}
        @block   = block
      end

      private

      def backend(host, &block)
        backend_factory.new(host, &block)
      end

      def backend_factory
        case @options[:backend]
        when Symbol
          SSHKit::Backend.const_get(@options[:backend].to_s.split('_').collect(&:capitalize).join)
        when String
          Kernel.const_get(@options[:backend])
        when nil
          SSHKit.config.backend
        else
          @options[:backend]
        end

      end
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
j-cap-recipes-0.0.18 lib/j-cap-recipes/sshkit_runner_patch.rb
j-cap-recipes-0.0.17 lib/j-cap-recipes/sshkit_runner_patch.rb
j-cap-recipes-0.0.16 lib/j-cap-recipes/sshkit_runner_patch.rb