require 'nitro/context' module Nitro module Request # Some useful mini methods for browser testing. # TODO: add testing for mac IE (an other platforms) # Different servers hold user agent in differnet # strings (unify this). def user_agent headers['HTTP_USER_AGENT'] || headers['USER-AGENT'] end def from_gecko? user_agent =~ /Gecko/ end alias_method :from_mozilla?, :from_gecko? def from_ie? user_agent =~ /MSIE/ end alias_method :from_msie?, :from_ie? def from_opera? user_agent =~ /Opera/ end def from_khtml? user_agent =~ /KTHML/ end alias_method :from_safari?, :from_khtml? def from_w3c? from_gecko? or from_khtml? or from_opera? end def from_osx? user_agent =~ /Mac OS X/ or user_agent =~ /Mac_PowerPC/ end def from_os9? end def from_mac? from_osx? or from_os9? end def from_unix? user_agent =~ /linux/ or user_agent =~ /FreeBSD/ end alias_method :from_linux?, :from_unix? def from_windows? user_agent =~ /Windows/ end end end # * Chris Farmiloe