Skip to content

Commit 20d513e

Browse files
committed
Fix hound warnings
1 parent db0b9d3 commit 20d513e

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

Pavel_Borisov/2/lib/machinery.rb

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,7 @@ def initialize(domain)
4040

4141
def check!
4242
begin
43-
http = Net::HTTP.new(@domain)
44-
http.open_timeout = 1
45-
http.read_timeout = 1
46-
start_time = Time.now
47-
response = http.get('/')
48-
end_time = Time.now
49-
@response_time = "#{((end_time - start_time) * 1000).round}ms"
50-
@code = response.code.to_i
51-
@body = response.body
52-
@status = :got_response
43+
timed_http_request
5344
rescue StandardError => e
5445
@status = :errored
5546
cause = ('Timeout' if e.is_a? Timeout::Error) || e.cause
@@ -68,6 +59,21 @@ def result
6859
"#{@domain} - hasn't been checked"
6960
end
7061
end
62+
63+
private
64+
65+
def timed_http_request
66+
http = Net::HTTP.new(@domain)
67+
http.open_timeout = 1
68+
http.read_timeout = 1
69+
start_time = Time.now.utc
70+
response = http.get('/')
71+
end_time = Time.now.utc
72+
@response_time = "#{((end_time - start_time) * 1000).round}ms"
73+
@code = response.code.to_i
74+
@body = response.body
75+
@status = :got_response
76+
end
7177
end
7278

7379
# Reads domains list from a file, filters the list according to the supplied options.

0 commit comments

Comments
 (0)