Class: Net::Knocker
- Inherits:
-
Object
show all
- Includes:
- Env
- Defined in:
- lib/net/knocker.rb,
lib/net/knocker/env.rb,
lib/net/knocker/peer.rb,
lib/net/knocker/version.rb
Defined Under Namespace
Modules: Env
Classes: Peer
Constant Summary
collapse
- VERSION =
'0.0.7'
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Env
#debug, #debugging?, #env_secret, #error, #http_client, #info, #log, #should_omit?, #ssl_certificate, #ssl_key, #url, #var_names, #warn
Class Method Details
.check ⇒ Object
11
12
13
|
# File 'lib/net/knocker.rb', line 11
def self.check
new
end
|
.should_omit? ⇒ Boolean
15
16
17
|
# File 'lib/net/knocker.rb', line 15
def self.should_omit?
new.should_omit?
end
|
Instance Method Details
#in ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'lib/net/knocker.rb', line 19
def in
return debug(omit_message('PUT')) if should_omit?
send_request('PUT').tap do |response|
@should_omit ||= response.code.start_with? '3'
end
end
|
#omit_message(http_method = 'DELETE') ⇒ Object
28
29
30
31
|
# File 'lib/net/knocker.rb', line 28
def omit_message(http_method = 'DELETE')
msg_end = url.to_s.empty? ? '' : "to #{url}"
"not sending #{http_method} request #{msg_end}"
end
|
#out ⇒ Object
33
34
35
36
37
38
|
# File 'lib/net/knocker.rb', line 33
def out
return debug(omit_message) if should_omit?
return info("#{omit_message}, blocked by PID(s) #{Peer.pids.join(',')}") if Peer.any?
send_request 'DELETE'
end
|