Sha256: 784b50ccb9707d0a96036f7c2faeb0b03d880906676d9a94aff9013df2524792

Contents?: true

Size: 713 Bytes

Versions: 3

Compression:

Stored size: 713 Bytes

Contents

%w{
murlsh
}.each { |m| require m }

module Murlsh

  # notify PubSubHubbub hubs that feed has been updated
  class AddPost60NotifyHubs < Plugin

    Hook = 'add_post'

    def self.run(config)
      hubs = config.fetch('pubsubhubbub_hubs', [])

      unless hubs.empty?
        require 'eventmachine'
        require 'pubsubhubbub'

        feed_url = URI.join(config['root_url'], config['feed_file'])

        hubs.each do |hub|
          EventMachine.run {
            pub = EventMachine::PubSubHubbub.new(hub['publish_url']).publish(
              feed_url)

            pub.callback { EventMachine.stop  }
            pub.errback { EventMachine.stop }
          }
        end

      end

    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
murlsh-0.8.1 plugins/add_post_60_notify_hubs.rb
murlsh-0.8.0 plugins/add_post_60_notify_hubs.rb
murlsh-0.7.0 plugins/add_post_60_notify_hubs.rb