class OStatus2::Publication

Public Class Methods

new(url, hubs = []) click to toggle source

@param [String] url Topic URL @param [Array] hubs URLs of the hubs which should be notified about the update

# File lib/ostatus2/publication.rb, line 5
def initialize(url, hubs = [])
  @url  = url
  @hubs = hubs.map { |hub_url| Addressable::URI.parse(hub_url) }
end

Public Instance Methods

publish() click to toggle source

Notifies hubs about the update to the topic URL @raise [HTTP::Error] Error raised upon delivery failure @raise [OpenSSL::SSL::SSLError] Error raised upon SSL-related failure during delivery

# File lib/ostatus2/publication.rb, line 13
def publish
  @hubs.each { |hub| http_client.post(hub, form: { 'hub.mode' => 'publish', 'hub.url' => @url }) }
end

Private Instance Methods

http_client() click to toggle source
# File lib/ostatus2/publication.rb, line 19
def http_client
  HTTP.timeout(:per_operation, write: 60, connect: 20, read: 60)
end