internet_connection 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/internet_connection.rb +3 -5
- metadata +4 -4
data/lib/internet_connection.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# :main: README.rdoc
|
2
|
-
|
3
1
|
require 'resolv'
|
4
2
|
require 'resolv-replace'
|
5
3
|
if RUBY_VERSION =~ /1.9.*/
|
@@ -12,11 +10,11 @@ if RUBY_VERSION =~ /1.9.*/
|
|
12
10
|
end
|
13
11
|
|
14
12
|
module InternetConnection
|
15
|
-
# InternetConnection#on? will try to resolve
|
13
|
+
# InternetConnection#on? will try to resolve a host with dns.
|
16
14
|
# if it can you've got an internet connection
|
17
|
-
def on?
|
15
|
+
def on?(host = 'www.example.com')
|
18
16
|
begin
|
19
|
-
!!Resolv.getaddress(
|
17
|
+
!!Resolv.getaddress(host)
|
20
18
|
rescue Errno::EHOSTUNREACH
|
21
19
|
return false
|
22
20
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: internet_connection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Diego Scataglini @_sc
|
@@ -62,6 +62,6 @@ rubyforge_project:
|
|
62
62
|
rubygems_version: 1.3.7
|
63
63
|
signing_key:
|
64
64
|
specification_version: 3
|
65
|
-
summary: Checks if the internet connection is on or off
|
65
|
+
summary: Checks if the internet connection is on or off. Useful for choosing CDN vs local assets, for example.
|
66
66
|
test_files: []
|
67
67
|
|