Skip to content
Browse files

i think i'm done with the notifo one... needs config.yml.example

  • Loading branch information...
1 parent 240647f commit 5faf96aa65b17bfbc173132039882e7a142030c3 Luke Carpenter committed May 25, 2011
Showing with 52 additions and 20 deletions.
  1. +31 −0 lib/notifo/notifo_runner.rb
  2. +21 −20 lib/notifo/notifo_worker.rb
View
31 lib/notifo/notifo_runner.rb
@@ -0,0 +1,31 @@
+require "simple_worker"
+require_relative "notifo_worker.rb"
+
+@y = YAML.load_file('./notifo.yml')
+
+w = SimpleWorker::Examples::NotifoWorker.new
+w.notifo_user = @y["notifo_service_user"]
+w.notifo_api = @y["notifo_service_key"]
+
+w.task = @y["notifo_task"].to_sym
+
+w.username = @y["username"]
+w.message = @y["message"]
+
+if @y["runlocal"] == true
+ w.run_local
+else
+ w.queue
+end
+
+puts "Job queued..."
+puts "I'll block until it's finished"
+
+w.wait_until_complete
+
+puts "Yay it finished!"
+puts "Here is it's log:"
+
+puts w.log
+
+puts "I exit now"
View
41 lib/notifo/notifo_worker.rb
@@ -13,27 +13,28 @@ class NotifoWorker < SimpleWorker::Base
# Sort of like ENV vars in Heroku
attr_accessor :notifo_user, :notifo_api
- # The SimpleWorker environment will invoke and run this def:
- def run
- notifo
-
- case @task
- when :subscribe then subscribe
- when :send then send
+ # The SimpleWorker environment will invoke and run this def:
+ def run
+ begin
+ log "connecting..."
+ @notifo = Notifo.new(@notifo_user, @notifo_api)
+ log "connected"
+
+ if @task == :subscribe
+ log "subscribing #{@username}"
+ @notifo.subscribe(@username)
+ # don't think there is anything else you can do with Notifo
+ else
+ log "sending #{@message} to #{@username}"
+ @notifo.post(@username, @message)
+ end
+ rescue => ex
+ log "ouchie"
+ log "#{ex.message} happened"
+ log "raising..."
+ raise ex
+ end
end
-
- end
-
- def notifo
- @notifo = Notifo.new(@notifo_user, @notifo_api)
- end
-
- def subscribe
- @notifo.subscribe_user(@username)
- end
-
- def send
- @notifo.post(@username, @message)
end
end
end

0 comments on commit 5faf96a

Please sign in to comment.
Something went wrong with that request. Please try again.