isup 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/bin/isup +1 -1
- data/lib/isup.rb +14 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OWQzZDBmNThjMzc1YTZhMjE4Y2ZjYTg2MWVmYmJlZTQ0M2Q1NjgxMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MWVkZDI5YzI5NjhhM2FkMDQ2YzVjZDIxZWMxMjE4ODJjZjQzZTUwNg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MzgwM2U3YzExMTg1NzlhYWI3NzU3ZjEwYzY5NjdlNmIyYTE0ZWM2ZWNhMDBj
|
10
|
+
NWY3ZjQ2YjU5MGVhMDgwZDg0MGRiMGJhNTEwZjVjNjQ5N2IxNDg1MDNmZGIx
|
11
|
+
ZWIzODJhNDE0MWQwZjQ2ZjI2Nzc4ZTVkNmMyZWI4N2Q2ZDJmNWM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTM4YmU0MTM5MjI4NjRhMGUxNWEzMGJlYzZhMmU2NWI2MGU1YWM2ZjgyYTNk
|
14
|
+
Njk5ZjliMWNmNTNhMTUyYzA0ODkwZGMzNzQ3MDY0ZDIzODAxYTg1MTE2MGZm
|
15
|
+
MzkyMGIyZjEyY2FlOWE4MjFiZGMwNjI4YWE5OTk5MTI5MDRjMTE=
|
data/bin/isup
CHANGED
data/lib/isup.rb
CHANGED
@@ -3,13 +3,19 @@ require "net/http"
|
|
3
3
|
# A simple class to determine whether a website is down.
|
4
4
|
class Isup
|
5
5
|
|
6
|
-
def initialize(
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
def initialize(args)
|
7
|
+
args.each do |x|
|
8
|
+
@url = x
|
9
|
+
@input_good = true
|
10
|
+
if (x == "-v") || (x == "--verbose")
|
11
|
+
@verbose = true
|
12
|
+
elsif valid?
|
13
|
+
up?
|
14
|
+
else
|
15
|
+
@input_good = false
|
16
|
+
end
|
12
17
|
end
|
18
|
+
puts "Please input a valid URL." if !@input_good
|
13
19
|
end
|
14
20
|
|
15
21
|
private
|
@@ -42,10 +48,9 @@ class Isup
|
|
42
48
|
begin
|
43
49
|
@response = Net::HTTP.get_response(URI(uri_str))
|
44
50
|
rescue SocketError
|
45
|
-
false
|
51
|
+
@up = false
|
46
52
|
rescue Errno::ECONNRESET
|
47
53
|
@up = true
|
48
|
-
false
|
49
54
|
else
|
50
55
|
case @response
|
51
56
|
when Net::HTTPSuccess then
|
@@ -56,6 +61,7 @@ class Isup
|
|
56
61
|
@up = false
|
57
62
|
when Net::HTTPRedirection then
|
58
63
|
@location = @response['location']
|
64
|
+
puts "Redirecting to #{@location}" if @verbose
|
59
65
|
fetch(@location, limit - 1)
|
60
66
|
else
|
61
67
|
warn "Unable to complete the request."
|