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.2".freeze
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.
78 79 80 81 82 |
# File 'lib/snitcher.rb', line 78 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.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/snitcher.rb', line 31 def snitch!(token, opts = {}) params = {} params[:m] = opts[:message] if opts[:message] # It's unnecessary to send an empty status if opts[:status] && opts[:status] != "" params[:s] = opts[:status] end uri = URI.parse(checkin_url(opts, token)) if params.any? uri.query = URI.encode_www_form(params) end 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 |