Skip to content

Instantly share code, notes, and snippets.

@satooshi
Created April 10, 2013 11:25
Show Gist options
  • Save satooshi/5353830 to your computer and use it in GitHub Desktop.
Save satooshi/5353830 to your computer and use it in GitHub Desktop.
pubsub task to notify to Hub server.
desc "notify to PuSH Hub server"
task :pubsub do
require 'net/http'
require 'uri'
hub_url = "http://satooshi.superfeedr.com" # <--- replace this with your hub
atom_url = "http://blog.satooshi.jp/atom.xml" # <--- replace this with your full feed url
resp, data = Net::HTTP.post_form(URI.parse(hub_url),
{'hub.mode' => 'publish',
'hub.url' => atom_url})
raise "!! Hub notification error: #{resp.code} #{resp.msg}, #{data}" unless resp.code == "204"
puts "## Notified hub (" + hub_url + ") that feed #{atom_url} has been updated"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment