Sha256: d76830a55bd7366224dce35590b8e965c7e62e15231dab50d942c5bea1e67aca

Contents?: true

Size: 930 Bytes

Versions: 16

Compression:

Stored size: 930 Bytes

Contents

module ::ProxyAPI
  class AvailableProxy

    HTTP_ERRORS = [
      EOFError,
      Errno::ECONNRESET,
      Errno::EINVAL,
      Net::HTTPBadResponse,
      Net::HTTPHeaderSyntaxError,
      Net::ProtocolError,
      Timeout::Error
    ].freeze

    def initialize(args)
      @args = args
    end

    def available?
      begin
        return true if has_scap_feature? && minimum_version
      rescue *HTTP_ERRORS
        return false
      end
      false
    end

    private

    def has_scap_feature?
      @features ||= ::ProxyAPI::Features.new(@args).features
      @features.include?('openscap')
    end

    def openscap_proxy_version
      @versions ||= ::ProxyAPI::Version.new(@args).proxy_versions['modules']
      @versions['openscap'] if @versions && @versions['openscap']
    end

    def minimum_version
      return false unless openscap_proxy_version
      openscap_proxy_version.to_f >= 0.5
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
foreman_openscap-0.7.13 app/lib/proxy_api/available_proxy.rb
foreman_openscap-0.7.12 app/lib/proxy_api/available_proxy.rb
foreman_openscap-0.7.11 app/lib/proxy_api/available_proxy.rb
foreman_openscap-0.7.10 app/lib/proxy_api/available_proxy.rb
foreman_openscap-0.8.3 app/lib/proxy_api/available_proxy.rb
foreman_openscap-0.7.9 app/lib/proxy_api/available_proxy.rb
foreman_openscap-0.7.8 app/lib/proxy_api/available_proxy.rb
foreman_openscap-0.7.7 app/lib/proxy_api/available_proxy.rb
foreman_openscap-0.8.2 app/lib/proxy_api/available_proxy.rb
foreman_openscap-0.7.6 app/lib/proxy_api/available_proxy.rb
foreman_openscap-0.8.1 app/lib/proxy_api/available_proxy.rb
foreman_openscap-0.7.5 app/lib/proxy_api/available_proxy.rb
foreman_openscap-0.8.0 app/lib/proxy_api/available_proxy.rb
foreman_openscap-0.7.4 app/lib/proxy_api/available_proxy.rb
foreman_openscap-0.7.3 app/lib/proxy_api/available_proxy.rb
foreman_openscap-0.7.2 app/lib/proxy_api/available_proxy.rb