Class: EventMachine::PubSubHubbub
- Inherits:
-
Object
- Object
- EventMachine::PubSubHubbub
- Includes:
- Deferrable, HttpEncoding
- Defined in:
- lib/pubsubhubbub/client.rb,
lib/pubsubhubbub/version.rb
Constant Summary collapse
- HEADERS =
{"User-Agent" => "PubSubHubbub Ruby", "Content-Type" => "application/x-www-form-urlencoded"}
- VERSION =
'0.2.0'
Instance Method Summary collapse
-
#initialize(hub, options = {}) ⇒ PubSubHubbub
constructor
A new instance of PubSubHubbub.
- #publish(*feeds) ⇒ Object
-
#subscribe(feed, callback, options = {}) ⇒ Object
These command will work only if the callback URL supports confirmation.
- #unsubscribe(feed, callback, options = {}) ⇒ Object
Constructor Details
#initialize(hub, options = {}) ⇒ PubSubHubbub
Returns a new instance of PubSubHubbub.
14 15 16 17 |
# File 'lib/pubsubhubbub/client.rb', line 14 def initialize(hub, ={}) @headers = HEADERS.merge([:head]) if [:head] @hub = hub.kind_of?(URI) ? hub : URI::parse(hub) end |
Instance Method Details
#publish(*feeds) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/pubsubhubbub/client.rb', line 19 def publish(*feeds) data = feeds.flatten.collect do |feed| form_encode_body({'hub.url' => feed, 'hub.mode' => 'publish'}) end.join("&") request(:body => data, :head => @headers) end |
#subscribe(feed, callback, options = {}) ⇒ Object
These command will work only if the callback URL supports confirmation.
28 |
# File 'lib/pubsubhubbub/client.rb', line 28 def subscribe(feed, callback, = {}); command('subscribe', feed, callback, ); end |
#unsubscribe(feed, callback, options = {}) ⇒ Object
29 |
# File 'lib/pubsubhubbub/client.rb', line 29 def unsubscribe(feed, callback, = {}); command('unsubscribe', feed, callback, ); end |