Skip to content

Instantly share code, notes, and snippets.

@dansimpson
Created December 4, 2009 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dansimpson/249401 to your computer and use it in GitHub Desktop.
Save dansimpson/249401 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'pp'
require 'logger'
$LOAD_PATH << File.dirname(__FILE__)
require 'proxy/base'
require 'proxy/wibox_proxy'
require 'sensors/reading'
require 'sensors/sensor'
require 'sensors/active_reading'
require 'tweeter'
Log = Logger.new(File.dirname(__FILE__) + "/processor.log");
#run the eventmachine, which streams data from the wibox
#and also tweets status every N minutes
EM.run {
sensor = Sensor.new
proxy = Proxy::WiboxProxy.new({
:host => "192.168.0.2",
:port => 8088,
:user => "ws",
:password => "test",
:auto_ack => true
})
proxy.on_data do |data|
reading = sensor.build_reading(data)
reading.save
puts reading.to_log_s
Log.info reading.to_log_s
end
proxy.on_announce do |data|
puts "ANNOUNCE! #{data}"
end
proxy.connect
#EM.add_periodic_timer(Settings.tweet_interval * 600) do
# processor.tweet
#end
Log.info "Tweeter is running!"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment