Module: Octokit::Client::PubSubHubbub
- Included in:
- Octokit::Client
- Defined in:
- lib/octokit/client/pub_sub_hubbub.rb
Overview
Methods for the PubSubHubbub API
Instance Method Summary collapse
-
#subscribe(topic, callback) ⇒ Boolean
Subscribe to a pubsub topic.
-
#subscribe_service_hook(repo, service_name, service_arguments = {}) ⇒ Object
Subscribe to a repository through pubsub.
-
#unsubscribe(topic, callback) ⇒ Boolean
Unsubscribe from a pubsub topic.
-
#unsubscribe_service_hook(repo, service_name) ⇒ Object
Unsubscribe repository through pubsub.
Instance Method Details
#subscribe(topic, callback) ⇒ Boolean
Subscribe to a pubsub topic
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/octokit/client/pub_sub_hubbub.rb', line 24 def subscribe(topic, callback) = { :"hub.callback" => callback, :"hub.mode" => "subscribe", :"hub.topic" => topic } response = pub_sub_hubbub_request() response.status == 204 end |
#subscribe_service_hook(repo, service_name, service_arguments = {}) ⇒ Object
Subscribe to a repository through pubsub
64 65 66 67 68 |
# File 'lib/octokit/client/pub_sub_hubbub.rb', line 64 def subscribe_service_hook(repo, service_name, service_arguments = {}) topic = "#{Octokit.web_endpoint}#{Repository.new(repo)}/events/push" callback = "github://#{service_name}?#{service_arguments.collect{ |k,v| [ k,v ].map{ |p| URI.encode_www_form_component(p) }.join("=") }.join("&") }" subscribe(topic, callback) end |
#unsubscribe(topic, callback) ⇒ Boolean
Unsubscribe from a pubsub topic
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/octokit/client/pub_sub_hubbub.rb', line 43 def unsubscribe(topic, callback) = { :"hub.callback" => callback, :"hub.mode" => "unsubscribe", :"hub.topic" => topic } response = pub_sub_hubbub_request() response.status == 204 end |
#unsubscribe_service_hook(repo, service_name) ⇒ Object
Unsubscribe repository through pubsub
78 79 80 81 82 |
# File 'lib/octokit/client/pub_sub_hubbub.rb', line 78 def unsubscribe_service_hook(repo, service_name) topic = "#{Octokit.web_endpoint}#{Repository.new(repo)}/events/push" callback = "github://#{service_name}" unsubscribe(topic, callback) end |