Sha256: ee54100c95d5dd5c8e9f847a6e4066b3d388df391ec8a736e0f38f9a09f0486a

Contents?: true

Size: 943 Bytes

Versions: 25

Compression:

Stored size: 943 Bytes

Contents

module SpecInfra
  module Helper
    module DetectOS
      def commands
        self.class.const_get('SpecInfra').const_get('Command').const_get(os[:family]).new
      end

      def os
        property[:os_by_host] = {} if ! property[:os_by_host]
        host_port = current_host_and_port

        if property[:os_by_host][host_port]
          os_by_host = property[:os_by_host][host_port]
        else
          # Set command object explicitly to avoid `stack too deep`
          os_by_host = backend(SpecInfra::Command::Base.new).check_os
          property[:os_by_host][host_port] = os_by_host
        end

        os_by_host
      end

      private

      # put this in a module for better reuse
      def current_host_and_port
        if SpecInfra.configuration.ssh
          [SpecInfra.configuration.ssh.host, SpecInfra.configuration.ssh.options[:port]]
        else
          ['localhost', nil]
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
specinfra-1.27.5 lib/specinfra/helper/detect_os.rb
specinfra-1.27.4 lib/specinfra/helper/detect_os.rb
specinfra-1.27.3 lib/specinfra/helper/detect_os.rb
specinfra-1.27.2 lib/specinfra/helper/detect_os.rb
specinfra-1.27.1 lib/specinfra/helper/detect_os.rb
specinfra-1.27.0 lib/specinfra/helper/detect_os.rb
specinfra-1.26.0 lib/specinfra/helper/detect_os.rb
specinfra-1.25.8 lib/specinfra/helper/detect_os.rb
specinfra-1.25.7 lib/specinfra/helper/detect_os.rb
specinfra-1.25.6 lib/specinfra/helper/detect_os.rb
specinfra-1.25.5 lib/specinfra/helper/detect_os.rb
specinfra-1.25.4 lib/specinfra/helper/detect_os.rb
specinfra-1.25.3 lib/specinfra/helper/detect_os.rb
specinfra-1.25.2 lib/specinfra/helper/detect_os.rb
specinfra-1.25.1 lib/specinfra/helper/detect_os.rb
specinfra-1.25.0 lib/specinfra/helper/detect_os.rb
specinfra-1.24.0 lib/specinfra/helper/detect_os.rb
specinfra-1.23.1 lib/specinfra/helper/detect_os.rb
specinfra-1.23.0 lib/specinfra/helper/detect_os.rb
specinfra-1.22.1 lib/specinfra/helper/detect_os.rb