Permalink
Browse files

Release 0.2.6.

  • Loading branch information...
1 parent 6641b40 commit dd1eee7fe1045dcd979900b6ae58d680f1bb4c28 @midas committed Jun 10, 2009
Showing with 50 additions and 8 deletions.
  1. +1 −1 guilded.gemspec
  2. +1 −1 lib/guilded.rb
  3. +33 −5 lib/guilded/browser_detector.rb
  4. +15 −1 lib/guilded/rails/view_helpers.rb
View
@@ -2,7 +2,7 @@
Gem::Specification.new do |s|
s.name = %q{guilded}
- s.version = "0.2.5"
+ s.version = "0.2.6"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["C. Jason Harrelson (midas)"]
View
@@ -73,7 +73,7 @@
# <%= g_load_alerter :skin => 'blueish', :id => 'load_alerter' %>
#
module Guilded
- VERSION = '0.2.5'
+ VERSION = '0.2.6'
end
ActionView::Base.send( :include, Guilded::Rails::ViewHelpers ) if defined?( ActionView )
@@ -1,6 +1,19 @@
module Guilded
+
+ # The BrowserDetector provides the ability to determine browser information from the user
+ # agent string.
+ #
class BrowserDetector
+ # Returns true if the browser matches the options ent in, otherwise returns false.
+ #
+ # === Request
+ # * +request+ - The request object.
+ #
+ # === Options
+ # * +:name+ - The name of the browser. For example 'ie'.
+ # * +:version+ - The version of the browser. For example '7'.
+ #
def self.browser_is?( request, options={} )
#name = name.to_s.strip
name = options[:name].to_s.strip
@@ -12,6 +25,11 @@ def self.browser_is?( request, options={} )
return true if name == 'webkit' && browser_name( request ) == 'safari'
end
+ # Returns the name of the browser that is making this request. For example 'ie'.
+ #
+ # === Request
+ # * +request+ - The request object.
+ #
def self.browser_name( request )
@browser_name ||= begin
ua = request.env['HTTP_USER_AGENT']
@@ -46,7 +64,21 @@ def self.browser_name( request )
end
end
end
+
+ # Returns the browser name concatenated with the browser version. for example, 'ie7'.
+ #
+ # === Request
+ # * +request+ - The request object.
+ #
+ def self.browser_full_name( request )
+ browser_name( request ) + browser_version( request )
+ end
+ # Returns the version of the browser that is making this request. For example '7'.
+ #
+ # === Request
+ # * +request+ - The request object.
+ #
def self.browser_version( request )
@browser_version ||= begin
ua = request.env['HTTP_USER_AGENT'].downcase
@@ -81,16 +113,12 @@ def self.can_use_png?
end
def self.all_browsers
- [ 'ie7', 'ie6', 'opera', 'firefox', 'netscape', 'konqueror', 'safari' ]
+ %W( ie7, ie6, opera, firefox, netscape, konqueror, safari )
end
def self.all_mobile_browsers
%w( ie4_ce )
end
- def self.all_formats
- %w( html, xml, mobile )
- end
-
end
end
@@ -83,16 +83,30 @@ def g_skin_tag( source, skin='default' )
end
end
- # returns the name of the browser that is making this request.
+ # Returns the name of the browser that is making this request. For example 'ie'.
#
def g_browser_name
Guilded::BrowserDetector.browser_name( request )
end
+ # Returns the version of the browser that is making this request. For example '7'.
+ #
def g_browser_version
Guilded::BrowserDetector.browser_version( request )
end
+ # Returns the browser name concatenated with the browser version. for example, 'ie7'.
+ #
+ def g_browser_full_name
+ Guilded::BrowserDetector.browser_full_name( request )
+ end
+
+ # Returns true if the browser matches the options ent in, otherwise returns false.
+ #
+ # === Options
+ # * +:name+ - The name of the browser. For example 'ie'.
+ # * +:version+ - The version of the browser. For example '7'.
+ #
def g_browser_is?( options={} )
Guilded::BrowserDetector.browser_is?( request, options )
end

0 comments on commit dd1eee7

Please sign in to comment.