Module: Snitcher
- Extended by:
- Snitcher
- Included in:
- Snitcher
- Defined in:
- lib/snitcher.rb,
lib/snitcher/api.rb,
lib/snitcher/version.rb
Defined Under Namespace
Modules: API
Constant Summary collapse
- VERSION =
"0.4.0"
Instance Method Summary collapse
-
#snitch(*args) ⇒ Boolean
Check-in to Dead Man’s Snitch.
-
#snitch!(token, opts = {}) ⇒ Boolean
Check-in to Dead Man’s Snitch, exceptions are raised on failures.
Instance Method Details
#snitch(*args) ⇒ Boolean
Check-in to Dead Man’s Snitch.
62 63 64 65 66 |
# File 'lib/snitcher.rb', line 62 def snitch(*args) snitch!(*args) rescue StandardError false end |
#snitch!(token, opts = {}) ⇒ Boolean
Check-in to Dead Man’s Snitch, exceptions are raised on failures.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/snitcher.rb', line 28 def snitch!(token, opts = {}) uri = URI.parse(checkin_url(opts, token)) uri.query = URI.encode_www_form(m: opts[:message]) if opts[:message] opts = initialize_opts(opts, uri) Net::HTTP.start(uri.host, uri.port, opts) do |http| request = Net::HTTP::Get.new(uri.request_uri) request["User-Agent"] = user_agent response = http.request(request) response.is_a?(Net::HTTPSuccess) end end |