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
webmock-3.11.0 spec/support/network_connection.rb
webmock-3.10.0 spec/support/network_connection.rb
webmock-3.9.5 spec/support/network_connection.rb
webmock-3.9.4 spec/support/network_connection.rb
webmock-3.9.3 spec/support/network_connection.rb
webmock-3.9.2 spec/support/network_connection.rb
vagrant-unbundled-2.2.10.0 vendor/bundle/ruby/2.7.0/gems/webmock-2.3.2/spec/support/network_connection.rb
webmock-3.9.1 spec/support/network_connection.rb
webmock-3.9.0 spec/support/network_connection.rb
vagrant-unbundled-2.2.9.0 vendor/bundle/ruby/2.7.0/gems/webmock-2.3.2/spec/support/network_connection.rb
vagrant-unbundled-2.2.8.0 vendor/bundle/ruby/2.7.0/gems/webmock-2.3.2/spec/support/network_connection.rb
webmock-3.8.3 spec/support/network_connection.rb
webmock-3.8.2 spec/support/network_connection.rb
webmock-3.8.1 spec/support/network_connection.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.7.0/gems/webmock-2.3.2/spec/support/network_connection.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.6.0/gems/webmock-2.3.2/spec/support/network_connection.rb
webmock-3.8.0 spec/support/network_connection.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/webmock-3.6.0/spec/support/network_connection.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/webmock-2.3.2/spec/support/network_connection.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/webmock-2.3.2/spec/support/network_connection.rb