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

Instance Method Details

#subscribe(topic, callback, secret = nil) ⇒ Boolean

Subscribe to a pubsub topic

Examples:

Subscribe to push events from one of your repositories, having an email sent when fired

client = Octokit::Client.new(:oauth_token = "token")
client.subscribe("https://github.com/joshk/devise_imapable/events/push", "github://Email?address=josh.kalderimis@gmail.com")

See Also:



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/octokit/client/pub_sub_hubbub.rb', line 26

def subscribe(topic, callback, secret = nil)
  options = {
    :hub.callback" => callback,
    :hub.mode" => "subscribe",
    :hub.topic" => topic
  }
  options.merge!(:hub.secret" => secret) unless secret.nil?

  response = pub_sub_hubbub_request(options)

  response.status == 204
end

#subscribe_service_hook(repo, service_name, service_arguments = {}, secret = nil) ⇒ Boolean

Subscribe to a repository through pubsub

Examples:

Subscribe to push events to one of your repositories to Travis-CI

client = Octokit::Client.new(:oauth_token = "token")
client.subscribe_service_hook('joshk/device_imapable', 'Travis', { :token => "test", :domain => "domain", :user => "user" })

See Also:



72
73
74
75
76
# File 'lib/octokit/client/pub_sub_hubbub.rb', line 72

def subscribe_service_hook(repo, service_name, service_arguments = {}, secret = nil)
  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, secret)
end

#unsubscribe(topic, callback) ⇒ Boolean

Unsubscribe from a pubsub topic

Examples:

Unsubscribe to push events from one of your repositories, no longer having an email sent when fired

client = Octokit::Client.new(:oauth_token = "token")
client.unsubscribe("https://github.com/joshk/devise_imapable/events/push", "github://Email?address=josh.kalderimis@gmail.com")

See Also:



48
49
50
51
52
53
54
55
56
57
# File 'lib/octokit/client/pub_sub_hubbub.rb', line 48

def unsubscribe(topic, callback)
  options = {
    :hub.callback" => callback,
    :hub.mode" => "unsubscribe",
    :hub.topic" => topic
  }
  response = pub_sub_hubbub_request(options)

  response.status == 204
end

#unsubscribe_service_hook(repo, service_name) ⇒ Object

Unsubscribe repository through pubsub

Examples:

Subscribe to push events to one of your repositories to Travis-CI

client = Octokit::Client.new(:oauth_token = "token")
client.unsubscribe_service_hook('joshk/device_imapable', 'Travis')

See Also:



87
88
89
90
91
# File 'lib/octokit/client/pub_sub_hubbub.rb', line 87

def unsubscribe_service_hook(repo, service_name)
  topic = "#{Octokit.web_endpoint}#{Repository.new(repo)}/events/push"
  callback = "github://#{service_name}"
  unsubscribe(topic, callback)
end