browsernizer 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/browsernizer.gemspec +1 -1
- data/lib/browsernizer/router.rb +1 -1
- data/lib/browsernizer/version.rb +1 -1
- data/spec/browsernizer/browser_spec.rb +4 -4
- data/spec/browsernizer/config_spec.rb +6 -6
- data/spec/browsernizer/router_spec.rb +6 -6
- metadata +13 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4cd0e2044b75ac34c7a4a68c72c7d6476748d4a
|
4
|
+
data.tar.gz: ff8042973932bfeaef12dbb5a0cb375292b590e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 907c615e77e885e99e4d50cd8371329ae3bcae81179c6e3f1c704a2d6e1d03dde254db00b992cb62441f9f5f67e00b0b96e7980ea13f37e8c6539f989ca81571
|
7
|
+
data.tar.gz: 5d7746684726e83324391cd9e486e6ab7acd24eb36562ecc9c5c42e1b7ca91dd2874dca1c6d0d483c984e0a8ff87de3581fa00510da260a0221228ccc7625af6
|
data/README.md
CHANGED
@@ -54,7 +54,7 @@ passed to it. If you wish to state that *mobile safari* is not supported, you
|
|
54
54
|
can declare it like this:
|
55
55
|
|
56
56
|
config.supported do |browser|
|
57
|
-
!(browser.name == "Safari" && browser.mobile?)
|
57
|
+
!(browser.name == "Safari" && browser.device.mobile?)
|
58
58
|
end
|
59
59
|
|
60
60
|
The block should return false to block the browser, true to allow it, and nil if it
|
@@ -62,7 +62,7 @@ cannot decide. This way you can make any arbitrary User-Agent explicitly allowed
|
|
62
62
|
even if its version would have been blocked otherwise:
|
63
63
|
|
64
64
|
config.supported do |browser|
|
65
|
-
true if browser.
|
65
|
+
true if browser.ua.include?('Linux')
|
66
66
|
end
|
67
67
|
|
68
68
|
Please note, that the order is important, thus the first block or requirement returning
|
data/browsernizer.gemspec
CHANGED
data/lib/browsernizer/router.rb
CHANGED
@@ -47,7 +47,7 @@ module Browsernizer
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def get_browsers(env)
|
50
|
-
raw_browser = ::Browser.new
|
50
|
+
raw_browser = ::Browser.new env["HTTP_USER_AGENT"]
|
51
51
|
browser = Browsernizer::Browser.new raw_browser.name.to_s, raw_browser.full_version.to_s
|
52
52
|
[raw_browser, browser]
|
53
53
|
end
|
data/lib/browsernizer/version.rb
CHANGED
@@ -5,12 +5,12 @@ describe Browsernizer::Browser do
|
|
5
5
|
describe "#meets?(requirement)" do
|
6
6
|
context "same vendor" do
|
7
7
|
it "returns true if version is >= to requirement" do
|
8
|
-
expect(browser("Chrome", "10.0").meets?(browser("Chrome", "10" ))).to
|
9
|
-
expect(browser("Chrome", "10.0").meets?(browser("Chrome", "10.1"))).to
|
10
|
-
expect(browser("Chrome", "10" ).meets?(browser("Chrome", " 9.1"))).to
|
8
|
+
expect(browser("Chrome", "10.0").meets?(browser("Chrome", "10" ))).to be true
|
9
|
+
expect(browser("Chrome", "10.0").meets?(browser("Chrome", "10.1"))).to be false
|
10
|
+
expect(browser("Chrome", "10" ).meets?(browser("Chrome", " 9.1"))).to be true
|
11
11
|
end
|
12
12
|
it "returns false if requirement version is set to false" do
|
13
|
-
expect(browser("Chrome", "10" ).meets?(browser("Chrome", false ))).to
|
13
|
+
expect(browser("Chrome", "10" ).meets?(browser("Chrome", false ))).to be false
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -13,7 +13,7 @@ describe Browsernizer::Config do
|
|
13
13
|
|
14
14
|
it "allows to unsupport browser by using false as version number" do
|
15
15
|
subject.supported "Chrome", false
|
16
|
-
expect(subject.get_supported[0].version).to
|
16
|
+
expect(subject.get_supported[0].version).to be false
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -29,11 +29,11 @@ describe Browsernizer::Config do
|
|
29
29
|
subject.exclude %r{^/assets}
|
30
30
|
subject.exclude "/foo/bar.html"
|
31
31
|
|
32
|
-
expect(subject.excluded?("/assets/foo.jpg")).to
|
33
|
-
expect(subject.excluded?("/Assets/foo.jpg")).to
|
34
|
-
expect(subject.excluded?("/prefix/assets/foo.jpg")).to
|
35
|
-
expect(subject.excluded?("/foo/bar.html")).to
|
36
|
-
expect(subject.excluded?("/foo/bar2.html")).to
|
32
|
+
expect(subject.excluded?("/assets/foo.jpg")).to be true
|
33
|
+
expect(subject.excluded?("/Assets/foo.jpg")).to be false
|
34
|
+
expect(subject.excluded?("/prefix/assets/foo.jpg")).to be false
|
35
|
+
expect(subject.excluded?("/foo/bar.html")).to be true
|
36
|
+
expect(subject.excluded?("/foo/bar2.html")).to be false
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -7,12 +7,12 @@ describe Browsernizer::Router do
|
|
7
7
|
subject do
|
8
8
|
Browsernizer::Router.new(app) do |config|
|
9
9
|
config.supported do |browser|
|
10
|
-
true if browser.
|
10
|
+
true if browser.ua.include?('Spec')
|
11
11
|
end
|
12
12
|
config.supported "Firefox", false
|
13
13
|
config.supported "Chrome", "7.1"
|
14
14
|
config.supported do |browser|
|
15
|
-
!(browser.safari? && browser.mobile?)
|
15
|
+
!(browser.safari? && browser.device.mobile?)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -27,7 +27,7 @@ describe Browsernizer::Router do
|
|
27
27
|
context "All Good" do
|
28
28
|
it "propagates request with updated env" do
|
29
29
|
expect(app).to receive(:call) do |env|
|
30
|
-
expect(env['browsernizer']['supported']).to
|
30
|
+
expect(env['browsernizer']['supported']).to be true
|
31
31
|
expect(env['browsernizer']['browser']).to eq("Chrome")
|
32
32
|
expect(env['browsernizer']['version']).to eq("7.1.1")
|
33
33
|
end
|
@@ -40,7 +40,7 @@ describe Browsernizer::Router do
|
|
40
40
|
context "location not set" do
|
41
41
|
it "propagates request with updated env" do
|
42
42
|
expect(app).to receive(:call) do |env|
|
43
|
-
expect(env['browsernizer']['supported']).to
|
43
|
+
expect(env['browsernizer']['supported']).to be false
|
44
44
|
end
|
45
45
|
subject.call(@env)
|
46
46
|
end
|
@@ -83,7 +83,7 @@ describe Browsernizer::Router do
|
|
83
83
|
end
|
84
84
|
it "propagates request with updated env" do
|
85
85
|
expect(app).to receive(:call) do |env|
|
86
|
-
expect(env['browsernizer']['supported']).to
|
86
|
+
expect(env['browsernizer']['supported']).to be false
|
87
87
|
end
|
88
88
|
subject.call(@env)
|
89
89
|
end
|
@@ -127,7 +127,7 @@ describe Browsernizer::Router do
|
|
127
127
|
|
128
128
|
it "propagates request" do
|
129
129
|
expect(app).to receive(:call) do |env|
|
130
|
-
expect(env['browsernizer']['supported']).to
|
130
|
+
expect(env['browsernizer']['supported']).to be true
|
131
131
|
end
|
132
132
|
subject.call(@env)
|
133
133
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: browsernizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Milovan Zogovic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -42,16 +42,22 @@ dependencies:
|
|
42
42
|
name: browser
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
- - "<"
|
46
49
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0
|
50
|
+
version: '3.0'
|
48
51
|
type: :runtime
|
49
52
|
prerelease: false
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
51
54
|
requirements:
|
52
|
-
- - "
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '2.0'
|
58
|
+
- - "<"
|
53
59
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0
|
60
|
+
version: '3.0'
|
55
61
|
description: Rack middleware for redirecting unsupported user agents to "please upgrade"
|
56
62
|
page
|
57
63
|
email:
|
@@ -99,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
105
|
version: '0'
|
100
106
|
requirements: []
|
101
107
|
rubyforge_project: browsernizer
|
102
|
-
rubygems_version: 2.4.
|
108
|
+
rubygems_version: 2.4.5.1
|
103
109
|
signing_key:
|
104
110
|
specification_version: 4
|
105
111
|
summary: Want friendly "please upgrade your browser" page? This gem is for you.
|