browser 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ require "test_helper"
2
+
3
+ class IosAppTest < Minitest::Test
4
+ let(:browser) { Browser.new(ua: $ua["IOS_WEBVIEW"]) }
5
+
6
+ test "detect as ios" do
7
+ assert browser.ios?
8
+ end
9
+
10
+ test "don't detect as safari" do
11
+ refute browser.safari?
12
+ end
13
+
14
+ test "detect as webview" do
15
+ assert browser.ios_webview?
16
+ end
17
+ end
@@ -0,0 +1,143 @@
1
+ require "test_helper"
2
+
3
+ class IosTest < Minitest::Test
4
+ setup do
5
+ @browser = Browser.new
6
+ end
7
+
8
+ test "detects iphone" do
9
+ @browser.ua = $ua["IPHONE"]
10
+
11
+ assert_equal "iPhone", @browser.name
12
+ assert @browser.iphone?
13
+ assert @browser.safari?
14
+ assert @browser.webkit?
15
+ assert @browser.mobile?
16
+ assert @browser.modern?
17
+ assert @browser.ios?
18
+ refute @browser.tablet?
19
+ refute @browser.mac?
20
+ assert_equal "3.0", @browser.full_version
21
+ assert_equal "3", @browser.version
22
+ end
23
+
24
+ test "detects safari" do
25
+ @browser.ua = $ua["SAFARI"]
26
+
27
+ assert_equal "Safari", @browser.name
28
+ assert @browser.safari?
29
+ assert @browser.webkit?
30
+ assert @browser.modern?
31
+ assert_equal "5.0.1", @browser.full_version
32
+ assert_equal "5", @browser.version
33
+ end
34
+
35
+ test "detects safari in webapp mode" do
36
+ @browser.ua = $ua["SAFARI_IPAD_WEBAPP_MODE"]
37
+ refute @browser.safari?
38
+ assert @browser.ios_webview?
39
+
40
+ @browser.ua = $ua["SAFARI_IPHONE_WEBAPP_MODE"]
41
+ refute @browser.safari?
42
+ assert @browser.ios_webview?
43
+ end
44
+
45
+ test "detects ipod" do
46
+ @browser.ua = $ua["IPOD"]
47
+
48
+ assert_equal "iPod Touch", @browser.name
49
+ assert @browser.ipod?
50
+ assert @browser.safari?
51
+ assert @browser.webkit?
52
+ assert @browser.mobile?
53
+ assert @browser.modern?
54
+ assert @browser.ios?
55
+ refute @browser.tablet?
56
+ refute @browser.mac?
57
+ assert_equal "3.0", @browser.full_version
58
+ assert_equal "3", @browser.version
59
+ end
60
+
61
+ test "detects ipad" do
62
+ @browser.ua = $ua["IPAD"]
63
+
64
+ assert_equal "iPad", @browser.name
65
+ assert @browser.ipad?
66
+ assert @browser.safari?
67
+ assert @browser.webkit?
68
+ assert @browser.modern?
69
+ assert @browser.ios?
70
+ assert @browser.tablet?
71
+ refute @browser.mobile?
72
+ refute @browser.mac?
73
+ assert_equal "4.0.4", @browser.full_version
74
+ assert_equal "4", @browser.version
75
+ end
76
+
77
+ test "detects ios4" do
78
+ @browser.ua = $ua["IOS4"]
79
+ assert @browser.ios?
80
+ assert @browser.ios?(4)
81
+ refute @browser.mac?
82
+ end
83
+
84
+
85
+ test "detects ios5" do
86
+ @browser.ua = $ua["IOS5"]
87
+ assert @browser.ios?
88
+ assert @browser.ios?(5)
89
+ refute @browser.mac?
90
+ end
91
+
92
+ test "detects ios6" do
93
+ @browser.ua = $ua["IOS6"]
94
+ assert @browser.ios?
95
+ assert @browser.ios?(6)
96
+ refute @browser.mac?
97
+ end
98
+
99
+ test "detects ios7" do
100
+ @browser.ua = $ua["IOS7"]
101
+ assert @browser.ios?
102
+ assert @browser.ios?(7)
103
+ refute @browser.mac?
104
+ end
105
+
106
+ test "detects ios8" do
107
+ @browser.ua = $ua["IOS8"]
108
+ assert @browser.ios?
109
+ assert @browser.ios?(8)
110
+ refute @browser.mac?
111
+ end
112
+
113
+ test "detects ios9" do
114
+ @browser.ua = $ua["IOS9"]
115
+ assert @browser.ios?
116
+ assert @browser.ios?(9)
117
+ refute @browser.mac?
118
+ end
119
+
120
+ test "don't detect as two different versions" do
121
+ @browser.ua = $ua["IOS8"]
122
+ assert @browser.ios?(8)
123
+ refute @browser.ios?(7)
124
+ end
125
+
126
+ test "warn about deprecated numbered version" do
127
+ message = "Browser#ios8? is deprecated; use Browser#ios?(version) instead"
128
+ assert_deprecated(message, __FILE__, __LINE__) { @browser.ios8? }
129
+ end
130
+
131
+ test "returns string representation for ios" do
132
+ @browser.ua = $ua["IPHONE"]
133
+ meta = @browser.to_s
134
+
135
+ assert meta.include?("iphone")
136
+ assert meta.include?("webkit")
137
+ assert meta.include?("ios")
138
+ assert meta.include?("safari")
139
+ assert meta.include?("safari3")
140
+ assert meta.include?("modern")
141
+ assert meta.include?("mobile")
142
+ end
143
+ end
@@ -0,0 +1,41 @@
1
+ require "test_helper"
2
+
3
+ class KindleTest < Minitest::Test
4
+ setup do
5
+ @browser = Browser.new
6
+ end
7
+
8
+ test "detects kindle monochrome" do
9
+ @browser.ua = $ua["KINDLE"]
10
+
11
+ assert @browser.kindle?
12
+ assert @browser.webkit?
13
+ end
14
+
15
+ test "detects kindle fire" do
16
+ @browser.ua = $ua["KINDLE_FIRE"]
17
+
18
+ assert @browser.kindle?
19
+ assert @browser.webkit?
20
+ end
21
+
22
+ test "detects kindle fire hd" do
23
+ @browser.ua = $ua["KINDLE_FIRE_HD"]
24
+
25
+ assert @browser.silk?
26
+ assert @browser.kindle?
27
+ assert @browser.webkit?
28
+ assert @browser.modern?
29
+ refute @browser.mobile?
30
+ end
31
+
32
+ test "detects kindle fire hd mobile" do
33
+ @browser.ua = $ua["KINDLE_FIRE_HD_MOBILE"]
34
+
35
+ assert @browser.silk?
36
+ assert @browser.kindle?
37
+ assert @browser.webkit?
38
+ assert @browser.modern?
39
+ assert @browser.mobile?
40
+ end
41
+ end
@@ -0,0 +1,13 @@
1
+ require "test_helper"
2
+
3
+ class NokiaTest < Minitest::Test
4
+ setup do
5
+ @browser = Browser.new(ua: $ua["NOKIA"])
6
+ end
7
+
8
+ test "detects Nokia S40" do
9
+ assert @browser.mobile?
10
+ assert @browser.nokia?
11
+ assert_equal @browser.name, "Nokia S40 Ovi Browser"
12
+ end
13
+ end
@@ -0,0 +1,46 @@
1
+ require "test_helper"
2
+
3
+ class OperaTest < Minitest::Test
4
+ setup do
5
+ @browser = Browser.new
6
+ end
7
+
8
+ test "detects opera" do
9
+ @browser.ua = $ua["OPERA"]
10
+
11
+ assert_equal "Opera", @browser.name
12
+ assert @browser.opera?
13
+ refute @browser.modern?
14
+ assert_equal "11.64", @browser.full_version
15
+ assert_equal "11", @browser.version
16
+ end
17
+
18
+ test "detects opera next" do
19
+ @browser.ua = $ua["OPERA_NEXT"]
20
+
21
+ assert_equal "Opera", @browser.name
22
+ assert_equal :opera, @browser.id
23
+ assert @browser.opera?
24
+ assert @browser.webkit?
25
+ assert @browser.modern?
26
+ refute @browser.chrome?
27
+ assert_equal "15.0.1147.44", @browser.full_version
28
+ assert_equal "15", @browser.version
29
+ end
30
+
31
+ test "detects opera mini" do
32
+ @browser.ua = $ua["OPERA_MINI"]
33
+
34
+ assert @browser.opera_mini?
35
+ refute @browser.tablet?
36
+ assert @browser.mobile?
37
+ end
38
+
39
+ test "detects opera mobi" do
40
+ @browser.ua = $ua["OPERA_MOBI"]
41
+
42
+ assert @browser.opera?
43
+ refute @browser.tablet?
44
+ assert @browser.mobile?
45
+ end
46
+ end
@@ -0,0 +1,18 @@
1
+ require "test_helper"
2
+
3
+ class ProxyTest < Minitest::Test
4
+ %w[
5
+ NOKIA
6
+ OPERA_MINI
7
+ UC_BROWSER
8
+ ].each do |name|
9
+ ua = $ua[name]
10
+
11
+ test "detect #{ua} as proxy" do
12
+ browser = Browser.new(ua: ua)
13
+
14
+ assert browser.proxy?
15
+ assert browser.meta.include?("proxy")
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,13 @@
1
+ require "test_helper"
2
+
3
+ class UcBrowserTest < Minitest::Test
4
+ setup do
5
+ @browser = Browser.new(ua: $ua["UC_BROWSER"])
6
+ end
7
+
8
+ test "detects UC Browser" do
9
+ assert @browser.mobile?
10
+ assert @browser.uc_browser?
11
+ assert_equal @browser.name, "UC Browser"
12
+ end
13
+ end
@@ -0,0 +1,54 @@
1
+ require "test_helper"
2
+
3
+ class WindowPhoneTest < Minitest::Test
4
+ setup do
5
+ @browser = Browser.new
6
+ end
7
+
8
+ test "detects windows phone" do
9
+ @browser.ua = $ua["WINDOWS_PHONE"]
10
+
11
+ assert @browser.ie?
12
+ assert_equal "7", @browser.version
13
+ assert @browser.mobile?
14
+ assert @browser.windows_phone?
15
+ refute @browser.windows_mobile?
16
+ refute @browser.tablet?
17
+ end
18
+
19
+ test "detects windows phone 8" do
20
+ @browser.ua = $ua["WINDOWS_PHONE8"]
21
+
22
+ assert @browser.ie?
23
+ assert_equal "10", @browser.version
24
+ assert @browser.mobile?
25
+ assert @browser.windows_phone?
26
+ refute @browser.windows_mobile?
27
+ refute @browser.tablet?
28
+ end
29
+
30
+ test "detects windows phone 8.1" do
31
+ @browser.ua = $ua["WINDOWS_PHONE_81"]
32
+
33
+ assert @browser.ie?
34
+ assert_equal "Internet Explorer", @browser.name
35
+ assert_equal :ie, @browser.id
36
+ assert_equal "11", @browser.version
37
+ assert_equal "11.0", @browser.full_version
38
+ assert @browser.mobile?
39
+ assert @browser.windows_phone?
40
+ refute @browser.windows_mobile?
41
+ refute @browser.tablet?
42
+ end
43
+
44
+ test "detects windows mobile (windows phone 8)" do
45
+ @browser.ua = $ua["WINDOWS_PHONE8"]
46
+
47
+ assert @browser.ie?
48
+ assert_equal "10", @browser.version
49
+ assert @browser.mobile?
50
+ assert @browser.windows_phone?
51
+ refute @browser.windows_mobile?
52
+ refute @browser.tablet?
53
+ end
54
+ end
@@ -0,0 +1,64 @@
1
+ require "test_helper"
2
+
3
+ class WindowsTest < Minitest::Test
4
+ setup do
5
+ @browser = Browser.new
6
+ end
7
+
8
+ test "detects windows x64" do
9
+ @browser.ua = $ua["IE10_X64_WINX64"]
10
+ assert @browser.windows_x64?
11
+ refute @browser.windows_wow64?
12
+ assert @browser.windows_x64_inclusive?
13
+ end
14
+
15
+ test "detects windows wow64" do
16
+ @browser.ua = $ua["WINDOWS_WOW64"]
17
+ refute @browser.windows_x64?
18
+ assert @browser.windows_wow64?
19
+ assert @browser.windows_x64_inclusive?
20
+ end
21
+
22
+ test "detects windows platform" do
23
+ @browser.ua = "Windows"
24
+ assert_equal :windows, @browser.platform
25
+ assert @browser.windows?
26
+ end
27
+
28
+ test "detects windows_xp" do
29
+ @browser.ua = $ua["WINDOWS_XP"]
30
+
31
+ assert @browser.windows?
32
+ assert @browser.windows_xp?
33
+ end
34
+
35
+ test "detects windows_vista" do
36
+ @browser.ua = $ua["WINDOWS_VISTA"]
37
+
38
+ assert @browser.windows?
39
+ assert @browser.windows_vista?
40
+ end
41
+
42
+ test "detects windows7" do
43
+ @browser.ua = $ua["WINDOWS7"]
44
+
45
+ assert @browser.windows?
46
+ assert @browser.windows7?
47
+ end
48
+
49
+ test "detects windows8" do
50
+ @browser.ua = $ua["WINDOWS8"]
51
+
52
+ assert @browser.windows?
53
+ assert @browser.windows8?
54
+ refute @browser.windows8_1?
55
+ end
56
+
57
+ test "detects windows8.1" do
58
+ @browser.ua = $ua["WINDOWS81"]
59
+
60
+ assert @browser.windows?
61
+ assert @browser.windows8?
62
+ assert @browser.windows8_1?
63
+ end
64
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: browser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-25 00:00:00.000000000 Z
11
+ date: 2015-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,6 +94,34 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry-meta
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: minitest-autotest
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
97
125
  description: Do some browser detection with Ruby.
98
126
  email:
99
127
  - fnando.vieira@gmail.com
@@ -124,8 +152,10 @@ files:
124
152
  - lib/browser/meta/mobile.rb
125
153
  - lib/browser/meta/modern.rb
126
154
  - lib/browser/meta/platform.rb
155
+ - lib/browser/meta/proxy.rb
127
156
  - lib/browser/meta/safari.rb
128
157
  - lib/browser/meta/webkit.rb
158
+ - lib/browser/methods/blackberry.rb
129
159
  - lib/browser/methods/bots.rb
130
160
  - lib/browser/methods/consoles.rb
131
161
  - lib/browser/methods/devices.rb
@@ -133,6 +163,7 @@ files:
133
163
  - lib/browser/methods/language.rb
134
164
  - lib/browser/methods/mobile.rb
135
165
  - lib/browser/methods/platform.rb
166
+ - lib/browser/methods/proxy.rb
136
167
  - lib/browser/methods/tv.rb
137
168
  - lib/browser/middleware.rb
138
169
  - lib/browser/middleware/context.rb
@@ -141,11 +172,28 @@ files:
141
172
  - lib/browser/rails.rb
142
173
  - lib/browser/version.rb
143
174
  - search_engines.yml
144
- - test/browser_spec.rb
145
- - test/middleware_spec.rb
175
+ - test/browser_test.rb
176
+ - test/middleware_test.rb
146
177
  - test/sample_app.rb
147
- - test/spec_helper.rb
178
+ - test/test_helper.rb
148
179
  - test/ua.yml
180
+ - test/unit/adobe_air_test.rb
181
+ - test/unit/android_test.rb
182
+ - test/unit/blackberry_test.rb
183
+ - test/unit/bots_test.rb
184
+ - test/unit/chrome_test.rb
185
+ - test/unit/console_test.rb
186
+ - test/unit/firefox_test.rb
187
+ - test/unit/ie_test.rb
188
+ - test/unit/ios_app_test.rb
189
+ - test/unit/ios_test.rb
190
+ - test/unit/kindle_test.rb
191
+ - test/unit/nokia_test.rb
192
+ - test/unit/opera_test.rb
193
+ - test/unit/proxy_test.rb
194
+ - test/unit/uc_browser_test.rb
195
+ - test/unit/windows_phone_test.rb
196
+ - test/unit/windows_test.rb
149
197
  homepage: http://github.com/fnando/browser
150
198
  licenses:
151
199
  - MIT
@@ -158,6 +206,9 @@ post_install_message: |2+
158
206
  # If this is important for you, please read #
159
207
  # https://github.com/fnando/browser#internet-explorer #
160
208
  # #
209
+ # iOS webviews and web apps aren't detect as Safari #
210
+ # anymore, so be aware of that if that's your case. #
211
+ # #
161
212
  ###########################################################
162
213
 
163
214
  rdoc_options: []
@@ -175,13 +226,30 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
226
  version: '0'
176
227
  requirements: []
177
228
  rubyforge_project:
178
- rubygems_version: 2.4.5
229
+ rubygems_version: 2.5.1
179
230
  signing_key:
180
231
  specification_version: 4
181
232
  summary: Do some browser detection with Ruby.
182
233
  test_files:
183
- - test/browser_spec.rb
184
- - test/middleware_spec.rb
234
+ - test/browser_test.rb
235
+ - test/middleware_test.rb
185
236
  - test/sample_app.rb
186
- - test/spec_helper.rb
237
+ - test/test_helper.rb
187
238
  - test/ua.yml
239
+ - test/unit/adobe_air_test.rb
240
+ - test/unit/android_test.rb
241
+ - test/unit/blackberry_test.rb
242
+ - test/unit/bots_test.rb
243
+ - test/unit/chrome_test.rb
244
+ - test/unit/console_test.rb
245
+ - test/unit/firefox_test.rb
246
+ - test/unit/ie_test.rb
247
+ - test/unit/ios_app_test.rb
248
+ - test/unit/ios_test.rb
249
+ - test/unit/kindle_test.rb
250
+ - test/unit/nokia_test.rb
251
+ - test/unit/opera_test.rb
252
+ - test/unit/proxy_test.rb
253
+ - test/unit/uc_browser_test.rb
254
+ - test/unit/windows_phone_test.rb
255
+ - test/unit/windows_test.rb