schmobile 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'rack/schmobile/filters/mobile_session'
|
1
2
|
require 'rack/schmobile/filters/is_mobile_param'
|
2
3
|
require 'rack/schmobile/filters/mobile_user_agent'
|
3
4
|
|
@@ -9,7 +10,24 @@ module Rack
|
|
9
10
|
#
|
10
11
|
# You can modify the chain to add new conditions that check on e.g. request format.
|
11
12
|
module Filters
|
12
|
-
CHAIN = [
|
13
|
+
CHAIN = [
|
14
|
+
Rack::Schmobile::Filters::MobileSession,
|
15
|
+
Rack::Schmobile::Filters::IsMobileParam,
|
16
|
+
Rack::Schmobile::Filters::MobileUserAgent
|
17
|
+
]
|
18
|
+
|
19
|
+
def self.apply(request)
|
20
|
+
Rack::Schmobile::Filters::CHAIN.each do |filter|
|
21
|
+
result = filter.call(request)
|
22
|
+
|
23
|
+
unless result.nil?
|
24
|
+
request.session[Rack::Schmobile::IS_MOBILE] = result
|
25
|
+
return result
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
false
|
30
|
+
end
|
13
31
|
end
|
14
32
|
end
|
15
33
|
end
|
@@ -4,10 +4,10 @@ module Rack
|
|
4
4
|
module IsMobileParam
|
5
5
|
def self.call(request)
|
6
6
|
if request.params.key?(Rack::Schmobile::IS_MOBILE)
|
7
|
-
|
7
|
+
return request.params[Rack::Schmobile::IS_MOBILE] == "true"
|
8
8
|
end
|
9
9
|
|
10
|
-
|
10
|
+
nil
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -2,12 +2,11 @@ module Rack
|
|
2
2
|
module Schmobile
|
3
3
|
module Request
|
4
4
|
def is_mobile?
|
5
|
-
|
6
|
-
|
7
|
-
return result unless result.nil?
|
5
|
+
unless defined?(@is_mobile)
|
6
|
+
@is_mobile = Rack::Schmobile::Filters.apply(self)
|
8
7
|
end
|
9
8
|
|
10
|
-
|
9
|
+
@is_mobile
|
11
10
|
end
|
12
11
|
|
13
12
|
def is_device?(identifier)
|
data/schmobile.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{schmobile}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Morten Primdahl"]
|
12
|
-
s.date = %q{2011-05-
|
12
|
+
s.date = %q{2011-05-27}
|
13
13
|
s.description = %q{Used to determine if a request is from a mobile client, and possibly redirect it if that's the case}
|
14
14
|
s.email = %q{morten@zendesk.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
"lib/rack/schmobile.rb",
|
28
28
|
"lib/rack/schmobile/filters.rb",
|
29
29
|
"lib/rack/schmobile/filters/is_mobile_param.rb",
|
30
|
+
"lib/rack/schmobile/filters/mobile_session.rb",
|
30
31
|
"lib/rack/schmobile/filters/mobile_user_agent.rb",
|
31
32
|
"lib/rack/schmobile/middleware.rb",
|
32
33
|
"lib/rack/schmobile/request_extension.rb",
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schmobile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Morten Primdahl
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-05-
|
18
|
+
date: 2011-05-27 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- lib/rack/schmobile.rb
|
117
117
|
- lib/rack/schmobile/filters.rb
|
118
118
|
- lib/rack/schmobile/filters/is_mobile_param.rb
|
119
|
+
- lib/rack/schmobile/filters/mobile_session.rb
|
119
120
|
- lib/rack/schmobile/filters/mobile_user_agent.rb
|
120
121
|
- lib/rack/schmobile/middleware.rb
|
121
122
|
- lib/rack/schmobile/request_extension.rb
|