Skip to content

Instantly share code, notes, and snippets.

@basyura
Created March 16, 2011 07:24
Show Gist options
  • Save basyura/872142 to your computer and use it in GitHub Desktop.
Save basyura/872142 to your computer and use it in GitHub Desktop.
earthquake-growler.rb
#!ruby
#-*- coding: utf-8 -*-
require 'ruby-growl'
require 'rss'
g = Growl.new 'localhost', 'ruby-growl', ['ruby-growl Notification']
g.notify 'ruby-growl Notification', 'earthquake', 'start'
uri = 'http://tenki.jp/component/static_api/rss/earthquake/recent_entries_by_day.xml'
update_time = Time.now
while true
RSS::Parser.parse(uri).items.reverse.each do |item|
next if item.date <= update_time
status = item.title + " - " + item.description
g.notify "ruby-growl Notification", "earthquake", status
update_time = item.date
end
puts "sleep ... last update is #{update_time.strftime("%H:%M:%S")}"
sleep 30
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment