Created
March 16, 2010 14:03
-
-
Save shingara/333981 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'eventmachine' | |
require 'feedzirra' | |
require 'restclient' | |
feeds_url = [ "http://stackoverflow.com/feeds/tag/ruby-on-rails", | |
"http://stackoverflow.com/feeds/tag/ruby", | |
"http://stackoverflow.com/feeds/tag/git", | |
"http://stackoverflow.com/feeds/tag/mongodb", | |
"http://stackoverflow.com/feeds/tag/nginx", | |
"http://stackoverflow.com/feeds/tag/capistrano", | |
"http://stackoverflow.com/feeds/tag/vim"] | |
EventMachine.run { | |
feeds = Feedzirra::Feed.fetch_and_parse(feeds_url).values | |
timer = EventMachine::PeriodicTimer.new(5) do | |
feeds.map do |feed| | |
Feedzirra::Feed.update(feed) | |
end | |
feeds.each do |feed| | |
if feed.updated? | |
feed.new_entries.each do |fe| | |
puts "new entries : #{fe.inspect}" | |
RestClient.post('http://open-notification.com/messages', | |
{'body'=> "News entries on feed #{fe.url} ", | |
'api_key' => 'xxxxx', | |
:message_kinds => {'0' => {'channel' => 'jabber', 'to' => 'cyril.mougel@gmail.com'}}}) | |
end | |
end | |
end | |
end | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment