browsernizer 0.1.5 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/README.md +11 -10
- data/browsernizer.gemspec +1 -1
- data/lib/browsernizer.rb +1 -1
- data/lib/browsernizer/router.rb +8 -8
- data/lib/browsernizer/version.rb +1 -1
- data/spec/browsernizer/router_spec.rb +2 -2
- metadata +12 -11
data/CHANGELOG
ADDED
data/README.md
CHANGED
@@ -47,12 +47,12 @@ If you wish to completely prevent some browsers from accessing website
|
|
47
47
|
config.supported "Internet Explorer", false
|
48
48
|
|
49
49
|
There is also an option to provide block for more advanced checking.
|
50
|
-
[
|
50
|
+
[Browser object](https://github.com/fnando/browser/blob/master/lib/browser.rb) will be
|
51
51
|
passed to it. If you wish to state that *mobile safari* is not supported, you
|
52
52
|
can declare it like this:
|
53
53
|
|
54
|
-
config.supported do |
|
55
|
-
!(
|
54
|
+
config.supported do |browser|
|
55
|
+
!(browser.name == "Safari" && browser.mobile?)
|
56
56
|
end
|
57
57
|
|
58
58
|
Specifying location is optional. If you prefer handling unsupported browsers on
|
@@ -85,14 +85,15 @@ You should specify browser name as a string. Here are the available options:
|
|
85
85
|
And some less popular:
|
86
86
|
|
87
87
|
* Android
|
88
|
-
* webOS
|
89
88
|
* BlackBerry
|
90
|
-
*
|
91
|
-
*
|
92
|
-
*
|
93
|
-
*
|
94
|
-
|
95
|
-
|
89
|
+
* iPad
|
90
|
+
* iPhone
|
91
|
+
* iPod Touch
|
92
|
+
* PlayStation Portable
|
93
|
+
* QuickTime
|
94
|
+
* Apple CoreMedia
|
95
|
+
|
96
|
+
Browser detection is done using [browser gem](https://github.com/fnando/browser).
|
96
97
|
|
97
98
|
|
98
99
|
|
data/browsernizer.gemspec
CHANGED
data/lib/browsernizer.rb
CHANGED
data/lib/browsernizer/router.rb
CHANGED
@@ -13,8 +13,8 @@ module Browsernizer
|
|
13
13
|
@env = env
|
14
14
|
@env["browsernizer"] = {
|
15
15
|
"supported" => true,
|
16
|
-
"browser" =>
|
17
|
-
"version" =>
|
16
|
+
"browser" => browser.name.to_s,
|
17
|
+
"version" => browser.version.to_s
|
18
18
|
}
|
19
19
|
handle_request
|
20
20
|
end
|
@@ -57,21 +57,21 @@ module Browsernizer
|
|
57
57
|
@config.get_location && @config.get_location == @env["PATH_INFO"]
|
58
58
|
end
|
59
59
|
|
60
|
-
def
|
61
|
-
::
|
60
|
+
def raw_browser
|
61
|
+
::Browser.new :ua => @env["HTTP_USER_AGENT"]
|
62
62
|
end
|
63
63
|
|
64
|
-
def
|
65
|
-
Browser.new
|
64
|
+
def browser
|
65
|
+
Browser.new raw_browser.name.to_s, raw_browser.full_version.to_s
|
66
66
|
end
|
67
67
|
|
68
68
|
# supported by default
|
69
69
|
def unsupported?
|
70
70
|
@config.get_supported.any? do |requirement|
|
71
71
|
supported = if requirement.respond_to?(:call)
|
72
|
-
requirement.call(
|
72
|
+
requirement.call(raw_browser)
|
73
73
|
else
|
74
|
-
|
74
|
+
browser.meets?(requirement)
|
75
75
|
end
|
76
76
|
supported === false
|
77
77
|
end
|
data/lib/browsernizer/version.rb
CHANGED
@@ -8,8 +8,8 @@ describe Browsernizer::Router do
|
|
8
8
|
Browsernizer::Router.new(app) do |config|
|
9
9
|
config.supported "Firefox", false
|
10
10
|
config.supported "Chrome", "7.1"
|
11
|
-
config.supported do |
|
12
|
-
!(
|
11
|
+
config.supported do |browser|
|
12
|
+
!(browser.safari? && browser.mobile?)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: browsernizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: &
|
16
|
+
requirement: &70211448089400 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70211448089400
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &70211448116560 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,18 +32,18 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70211448116560
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
38
|
-
requirement: &
|
37
|
+
name: browser
|
38
|
+
requirement: &70211448115820 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 0.4
|
43
|
+
version: 0.1.4
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70211448115820
|
47
47
|
description: Rack middleware for redirecting unsupported user agents to "please upgrade"
|
48
48
|
page
|
49
49
|
email:
|
@@ -53,6 +53,7 @@ extensions: []
|
|
53
53
|
extra_rdoc_files: []
|
54
54
|
files:
|
55
55
|
- .gitignore
|
56
|
+
- CHANGELOG
|
56
57
|
- Gemfile
|
57
58
|
- LICENSE
|
58
59
|
- README.md
|
@@ -91,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
92
|
version: '0'
|
92
93
|
requirements: []
|
93
94
|
rubyforge_project: browsernizer
|
94
|
-
rubygems_version: 1.8.
|
95
|
+
rubygems_version: 1.8.11
|
95
96
|
signing_key:
|
96
97
|
specification_version: 3
|
97
98
|
summary: Want friendly "please upgrade your browser" page? This gem is for you.
|