Sha256: e7d092855ddfccf51e28698081112955185b427e7a697a57e7af20426522523e

Contents?: true

Size: 1016 Bytes

Versions: 1

Compression:

Stored size: 1016 Bytes

Contents

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

    module Backend
      def backend_for(type)
        if ! respond_to?(:commands)
          commands_object = self.class.const_get(SPEC_TYPE).const_get('Commands').const_get('Base').new
        end
        instance = self.class.const_get('SpecInfra').const_get('Backend').const_get("#{type.to_s.capitalize}").instance
        instance.set_commands(commands_object || commands)
        instance
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
specinfra-0.0.5 lib/specinfra/helper/backend.rb