Sha256: b600cb77f041509423e39112aa91f06f4007e4e991eeb70a2ebe088ac7937ebb

Contents?: true

Size: 953 Bytes

Versions: 1

Compression:

Stored size: 953 Bytes

Contents

module SpecInfra
  module Helper
    ['Exec', 'Ssh', 'Cmd', 'WinRM', 'ShellScript', 'Dockerfile'].each do |type|
      eval <<-EOF
        module #{type}
          def backend(commands_object=nil)
            called_by_detect_os = caller[0] =~ /detect_os\.rb/
            if ! respond_to?(:commands) || called_by_detect_os
              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

1 entries across 1 versions & 1 rubygems

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