mobile-fu 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/mobile-fu.rb +24 -1
  2. data/lib/mobile-fu/version.rb +1 -1
  3. metadata +62 -78
data/lib/mobile-fu.rb CHANGED
@@ -44,6 +44,22 @@ module ActionController
44
44
  helper_method :is_device?
45
45
  helper_method :mobile_device
46
46
  end
47
+
48
+ # Add this to your controllers to prevent the mobile format from being set for specific actions
49
+ # class AwesomeController < ApplicationController
50
+ # has_no_mobile_fu_for :index
51
+ #
52
+ # def index
53
+ # # Mobile format will not be set, even if user is on a mobile device
54
+ # end
55
+ #
56
+ # def show
57
+ # # Mobile format will be set as normal here if user is on a mobile device
58
+ # end
59
+ # end
60
+ def has_no_mobile_fu_for(*actions)
61
+ @mobile_exempt_actions = actions
62
+ end
47
63
  end
48
64
 
49
65
  module InstanceMethods
@@ -64,7 +80,7 @@ module ActionController
64
80
  # the user has opted to use either the 'Standard' view or 'Mobile' view.
65
81
 
66
82
  def set_mobile_format
67
- if is_mobile_device? && !request.xhr?
83
+ if !mobile_exempt? && is_mobile_device? && !request.xhr?
68
84
  request.format = session[:mobile_view] == false ? :html : :mobile
69
85
  session[:mobile_view] = true if session[:mobile_view].nil?
70
86
  end
@@ -95,6 +111,13 @@ module ActionController
95
111
  def is_device?(type)
96
112
  request.user_agent.to_s.downcase.include? type.to_s.downcase
97
113
  end
114
+
115
+ # Returns true if current action isn't supposed to use mobile format
116
+ # See #has_no_mobile_fu_for
117
+
118
+ def mobile_exempt?
119
+ self.class.instance_variable_get("@mobile_exempt_actions").try(:include?, params[:action].to_sym)
120
+ end
98
121
  end
99
122
  end
100
123
 
@@ -1,3 +1,3 @@
1
1
  module MobileFu
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,85 +1,71 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: mobile-fu
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 2
8
- - 1
9
- version: 0.2.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Brendan Lim
13
9
  - Ben Langfeld
14
10
  autorequire:
15
11
  bindir: bin
16
12
  cert_chain: []
17
-
18
- date: 2011-07-30 00:00:00 +01:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
13
+ date: 2012-01-06 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
22
16
  name: rails
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &2152669900 !ruby/object:Gem::Requirement
25
18
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- segments:
30
- - 0
31
- version: "0"
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
32
23
  type: :runtime
33
- version_requirements: *id001
34
- - !ruby/object:Gem::Dependency
35
- name: rack-mobile-detect
36
24
  prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: *2152669900
26
+ - !ruby/object:Gem::Dependency
27
+ name: rack-mobile-detect
28
+ requirement: &2152669480 !ruby/object:Gem::Requirement
38
29
  none: false
39
- requirements:
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- segments:
43
- - 0
44
- version: "0"
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
45
34
  type: :runtime
46
- version_requirements: *id002
47
- - !ruby/object:Gem::Dependency
48
- name: rspec
49
35
  prerelease: false
50
- requirement: &id003 !ruby/object:Gem::Requirement
36
+ version_requirements: *2152669480
37
+ - !ruby/object:Gem::Dependency
38
+ name: rspec
39
+ requirement: &2152669040 !ruby/object:Gem::Requirement
51
40
  none: false
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- segments:
56
- - 0
57
- version: "0"
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
58
45
  type: :development
59
- version_requirements: *id003
60
- - !ruby/object:Gem::Dependency
61
- name: rdoc
62
46
  prerelease: false
63
- requirement: &id004 !ruby/object:Gem::Requirement
47
+ version_requirements: *2152669040
48
+ - !ruby/object:Gem::Dependency
49
+ name: rdoc
50
+ requirement: &2152668620 !ruby/object:Gem::Requirement
64
51
  none: false
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- segments:
69
- - 0
70
- version: "0"
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
71
56
  type: :development
72
- version_requirements: *id004
73
- description: Want to automatically detect mobile devices that access your Rails application? Mobile Fu allows you to do just that. People can access your site from a Palm, Blackberry, iPhone, iPad, Nokia, etc. and it will automatically adjust the format of the request from :html to :mobile.
74
- email:
57
+ prerelease: false
58
+ version_requirements: *2152668620
59
+ description: Want to automatically detect mobile devices that access your Rails application?
60
+ Mobile Fu allows you to do just that. People can access your site from a Palm, Blackberry,
61
+ iPhone, iPad, Nokia, etc. and it will automatically adjust the format of the request
62
+ from :html to :mobile.
63
+ email:
75
64
  - brendangl@gmail.com, ben@langfeld.me
76
65
  executables: []
77
-
78
66
  extensions: []
79
-
80
67
  extra_rdoc_files: []
81
-
82
- files:
68
+ files:
83
69
  - .gitignore
84
70
  - CHANGELOG
85
71
  - Gemfile
@@ -92,38 +78,36 @@ files:
92
78
  - mobile-fu.gemspec
93
79
  - spec/mobilized_styles_spec.rb
94
80
  - spec/spec_helper.rb
95
- has_rdoc: true
96
81
  homepage: https://github.com/benlangfeld/mobile-fu
97
82
  licenses: []
98
-
99
83
  post_install_message:
100
84
  rdoc_options: []
101
-
102
- require_paths:
85
+ require_paths:
103
86
  - lib
104
- required_ruby_version: !ruby/object:Gem::Requirement
87
+ required_ruby_version: !ruby/object:Gem::Requirement
105
88
  none: false
106
- requirements:
107
- - - ">="
108
- - !ruby/object:Gem::Version
109
- segments:
89
+ requirements:
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ segments:
110
94
  - 0
111
- version: "0"
112
- required_rubygems_version: !ruby/object:Gem::Requirement
95
+ hash: -872617584475517000
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
97
  none: false
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- segments:
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ segments:
118
103
  - 0
119
- version: "0"
104
+ hash: -872617584475517000
120
105
  requirements: []
121
-
122
106
  rubyforge_project: mobile-fu
123
- rubygems_version: 1.3.7
107
+ rubygems_version: 1.8.10
124
108
  signing_key:
125
109
  specification_version: 3
126
110
  summary: Automatically detect mobile requests from mobile devices in your Rails application.
127
- test_files:
111
+ test_files:
128
112
  - spec/mobilized_styles_spec.rb
129
113
  - spec/spec_helper.rb