lib/messenger.rb in messenger-0.1.1 vs lib/messenger.rb in messenger-0.2.0

- old
+ new

@@ -1,9 +1,8 @@ $:.unshift File.dirname(__FILE__) require 'rubygems' -require 'ruby-debug' require 'messenger/errors' require 'system_timer' module Messenger @@ -21,10 +20,12 @@ def self.valid_url?(url) service_handler = handler(url) service_handler.valid_url?(url) + rescue ProtocolError + false end def self.send(url, message, options={}) service_handler = handler(url) SystemTimer.timeout_after(options[:timeout] || 15) do @@ -42,23 +43,25 @@ # TODO: More services # sms://1231231234 # twitter://username # aim://username case url - when /^mailto/: :email - when /^http/: :http - when /^campfire/: :campfire - when /^jabber/: :jabber + when /^http/: :http + when /^campfire/: :campfire + when /^jabber/: :jabber + when /^notifo/: :notifo + when /^mailto|@+/: :email end end def self.handler(url) case protocol(url) when :email: Email when :http: Web when :campfire: Campfire when :jabber: Jabber + when :notifo: Notifo else raise ProtocolError, "Malformed service URL: #{url}. Either this syntax is wrong or this service type is not yet implemented." end end @@ -66,7 +69,8 @@ autoload :Result, "messenger/result" autoload :Email, "messenger/email" autoload :Web, "messenger/web" autoload :Campfire, "messenger/campfire" autoload :Jabber, "messenger/jabber" + autoload :Notifo, "messenger/notifo" end