Sha256: 43c8e82b1b5b42e1622a14eb73c4b62220e891c1dca0c01f8d474f2270e2f115

Contents?: true

Size: 321 Bytes

Versions: 108

Compression:

Stored size: 321 Bytes

Contents

require 'timeout'
require 'socket'

module NetworkConnection
  def self.connect_to(host, port, timeout=10)
    Timeout.timeout(timeout) do
      TCPSocket.new(host, port)
    end
  end

  def self.is_network_available?
    begin
      self.connect_to("8.8.8.8", 53, 5)
      true
    rescue
      false
    end
  end
end

Version data entries

108 entries across 102 versions & 8 rubygems

Version Path
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/webmock-2.3.2/spec/support/network_connection.rb
webmock-3.7.6 spec/support/network_connection.rb
webmock-3.7.5 spec/support/network_connection.rb
webmock-3.7.4 spec/support/network_connection.rb
webmock-3.7.3 spec/support/network_connection.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/webmock-2.3.2/spec/support/network_connection.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/webmock-2.3.2/spec/support/network_connection.rb
webmock-3.7.2 spec/support/network_connection.rb
webmock-3.7.1 spec/support/network_connection.rb
webmock-3.7.0 spec/support/network_connection.rb
webmock-3.6.2 spec/support/network_connection.rb
webmock-3.6.0 spec/support/network_connection.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/webmock-2.3.2/spec/support/network_connection.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.6.0/gems/webmock-2.3.2/spec/support/network_connection.rb
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/webmock-2.3.2/spec/support/network_connection.rb
webmock-3.5.1 spec/support/network_connection.rb
webmock-3.5.0 spec/support/network_connection.rb
vagrant-unbundled-2.2.2.0 vendor/bundle/ruby/2.5.0/gems/webmock-2.3.2/spec/support/network_connection.rb
vagrant-unbundled-2.2.0.0 vendor/bundle/ruby/2.5.0/gems/webmock-2.3.2/spec/support/network_connection.rb
vagrant-unbundled-2.1.4.0 vendor/bundle/ruby/2.5.0/gems/webmock-2.3.2/spec/support/network_connection.rb