Skip to content

Commit

Permalink
Refactor the user agent list to the tablet module.
Browse files Browse the repository at this point in the history
  • Loading branch information
darrencauthon committed Dec 1, 2013
1 parent 619f210 commit 93d8da2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 1 addition & 4 deletions lib/mobile-fu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ class Railtie < Rails::Railtie

module ActionController
module MobileFu
# These are various strings that can be found in tablet devices. Please feel free
# to add on to this list.
TABLET_USER_AGENTS = /ipad|android 3.0|xoom|sch-i800|gt-p1000|playbook|tablet|kindle|honeycomb|nexus 7|windows nt [0-9.]+; arm/.freeze

def self.included(base)
base.extend ClassMethods
Expand Down Expand Up @@ -158,7 +155,7 @@ def in_tablet_view?
# the device making the request is matched to a device in our regex.

def is_tablet_device?
!!(request.user_agent.to_s.downcase =~ ActionController::MobileFu::TABLET_USER_AGENTS)
!!(request.user_agent.to_s.downcase =~ ::MobileFu::Tablet.user_agents)
end

def is_mobile_device?
Expand Down
5 changes: 5 additions & 0 deletions lib/mobile-fu/tablet.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
module MobileFu
module Tablet

def self.user_agents
/ipad|android 3.0|xoom|sch-i800|gt-p1000|playbook|tablet|kindle|honeycomb|nexus 7|windows nt [0-9.]+; arm/.freeze
end

end
end

0 comments on commit 93d8da2

Please sign in to comment.