Skip to content

Commit

Permalink
Moving ServiceHooks under PubSubHubBub module.
Browse files Browse the repository at this point in the history
  • Loading branch information
ifesdjeen committed Jun 13, 2011
1 parent 7710e45 commit babb695
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 46 deletions.
4 changes: 2 additions & 2 deletions lib/octokit/client.rb
Expand Up @@ -9,7 +9,7 @@
require 'octokit/client/objects'
require 'octokit/client/organizations'
require 'octokit/client/pub_sub_hub_bub'
require 'octokit/client/service_hooks'
require 'octokit/client/pub_sub_hub_bub/service_hooks'
require 'octokit/client/pulls'
require 'octokit/client/repositories'
require 'octokit/client/timelines'
Expand Down Expand Up @@ -38,7 +38,7 @@ def initialize(options={})
include Octokit::Client::Organizations
include Octokit::Client::Pulls
include Octokit::Client::PubSubHubBub
include Octokit::Client::ServiceHooks
include Octokit::Client::PubSubHubBub::ServiceHooks
include Octokit::Client::Repositories
include Octokit::Client::Timelines
include Octokit::Client::Users
Expand Down
45 changes: 45 additions & 0 deletions lib/octokit/client/pub_sub_hub_bub/service_hooks.rb
@@ -0,0 +1,45 @@
module Octokit
class Client
module PubSubHubBub
module ServiceHooks

#
# Subscribe to a repository through pubsub
#
# @param owner [String] owner of mentioned repository
# @param repository [String] repository name
# @param service_name [String] service name owner
# @param service_arguments [Hash] params that will be passed by subscibed hook.
# List of services is available @ https://github.com/github/github-services/tree/master/docs.
# Please refer Data node for complete list of arguments.
# @example 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" })
def subscribe_service_hook(owner, repository, service_name, service_arguments = {})

This comment has been minimized.

Copy link
@catsby

catsby Jun 29, 2011

Contributor

Is there a reason why we break convention here and specify user, repository parameters, instead of using a single Repository object? See octokit/client/issues.rb for an example of what I mean

This comment has been minimized.

Copy link
@ifesdjeen

ifesdjeen Jun 29, 2011

Author Contributor

If [String, Repository, Hash] is working, i think it'll be a good solution. Docs in issues.rb say it should be like that.

topic = "https://github.com/#{owner}/#{repository}/events/push"
callback = "github://#{service_name}?#{service_arguments.collect{ |k,v| [ k,v ].join("=") }.join("&") }"
subscribe(topic, callback)
true
end

#
# Unsubscribe repository through pubsub
#
# @param owner [String] owner of mentioned repository
# @param repository [String] repository name
# @param service_name [String] service name owner
# List of services is available @ https://github.com/github/github-services/tree/master/docs.
# @example 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')
def unsubscribe_service_hook(owner, repository, service_name)
topic = "https://github.com/#{owner}/#{repository}/events/push"
callback = "github://#{service_name}"
unsubscribe(topic, callback)
true
end

end
end
end
end
43 changes: 0 additions & 43 deletions lib/octokit/client/service_hooks.rb

This file was deleted.

@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
require 'helper'

describe Octokit::Client::ServiceHooks do
describe Octokit::Client::PubSubHubBub::ServiceHooks do

let(:client) { Octokit::Client.new(:oauth_token => 'myfaketoken') }

Expand Down

0 comments on commit babb695

Please sign in to comment.