Sha256: 69e46d188b1221f316d6084bdcc05f990f859fc9a57e5f2cc17e2e94014acef3

Contents?: true

Size: 883 Bytes

Versions: 65

Compression:

Stored size: 883 Bytes

Contents

module SpecInfra
  module Helper
    ['Exec', 'Ssh', 'Cmd', 'Docker', 'WinRM', 'ShellScript', 'Dockerfile', 'Lxc'].each do |type|
      eval <<-EOF
        module #{type}
          def backend(commands_object=nil)
            if ! respond_to?(:commands)
              commands_object = SpecInfra::Command::Base.new
            end
            instance = SpecInfra::Backend::#{type}.instance
            instance.set_commands(commands_object || commands)
            instance
          end
        end
      EOF
    end

    module Backend
      def backend_for(type)
        instance = self.class.const_get('SpecInfra').const_get('Backend').const_get(type.to_s.capitalize).instance
        commands = self.class.const_get('SpecInfra').const_get('Command').const_get(instance.check_os[:family]).new
        instance.set_commands(commands)
        instance
      end
    end
  end
end

Version data entries

65 entries across 65 versions & 1 rubygems

Version Path
specinfra-0.7.2 lib/specinfra/helper/backend.rb
specinfra-0.7.1 lib/specinfra/helper/backend.rb
specinfra-0.7.0 lib/specinfra/helper/backend.rb
specinfra-0.6.1 lib/specinfra/helper/backend.rb
specinfra-0.6.0 lib/specinfra/helper/backend.rb