prowly

Yet another Ruby interface to Prowl with command line utility

Installation

gem install prowly

Usage as a Gem

Prowly.notify do |n| # :notify is an alias of :add n.apikey = “apikey” or n.apikeys = [“apikey_1”, “apikey_2”, “apikey_n”] n.priority = Prowly::Notification::Priority::MODERATE n.application = “Prowly” n.event = “Notification” n.description = “Your server is under attack!!!” end notification = Prowly::Notification.new(:apikey => “apikey”, :application => “Prowly”, :description => “Testing…”) notification = Prowly::Notification.new(:apikeys => [“apikey_1”, “apikey_2”, “apikey_n”], :application => “Prowly”, :description => “Testing…”) result = Prowly.notify(notification)

Usage in the command line

$prowly -h # help $prowly -k one_apikey -a “the application” -e “the event” -d “the description” -p NORMAL $prowly -k key_1,key_2,key_n -a “the application” -e “the event” Options: -k, –api-key APIKEY Prowl API Key -d, –description DESCRIPTION Description -e, –event EVENT Event -p, –priority PRIORITY VERY_LOW, MODERATE, NORMAL (default), HIGH, EMERGENCY -v, –version Print the version number and exit If you only specify the apikey prowly will use the defaults:

:description => “I am testing Prowly, and it works!” :event => “Prowly notification” :application => “Prowly” :priority => NORMAL

Handling the Prowl API response

ON SUCCESS result.status # => “success” result.code # => “200”

if result.succeeded? result.remaining # => “977” resetdate.resetdate # => “1266272588” else resetdate.message # => end ON ERROR result.status # => “error” result.code # => “401” <= This depends on the error code sent by the prowl API

if result.succeeded? result.remaining # => resetdate.resetdate # => else resetdate.message # => “Invalid API Key(s)” <= This depends on the message sent by the prowl API end

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Copyright © 2010 Rafael Magaña. See LICENSE for details.