browser 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a8f4650e2d1a3d6e81011637c57feea62b92444b
4
- data.tar.gz: 6383b04357145bfd6acf774c235b1af3b71d4399
3
+ metadata.gz: 93f6d12da42a0b1944f3fb44ed75614d02e51e20
4
+ data.tar.gz: 876e5220638da02b508fb0070333d5c6426847c9
5
5
  SHA512:
6
- metadata.gz: 69effb2ac78f0bd154b38aa43a479dc5f42e29fce57bf702fe8521981122cca202e4fa35692a3f6e1b2e359906387cc086ee9b4a8102d2d0cf67819fdf9a718e
7
- data.tar.gz: b2c1172bc85607ceb885006a842837ac68d2e54c5443ab9885bcc17cd2c77a3aa779836d57f4037f9f72a1c561add97ce3221c25843af5362ed6f498de48e374
6
+ metadata.gz: ae24a76b7d3ea2dd0737c870605a5cff9c7347aa41474da7a478f17f06272fa21dffbb1eb5ab612e225153cc9727c8761987a48ccde24ad68e4a297f4f58f691
7
+ data.tar.gz: bca7fb51b2bd60ccb4f3fda10e4df85af44312d577bd4a825fa8f4b7a2fe4a5adcedaab1d54e983db46b6f71a187e046a204f370c676b81bfb2001f7ee088efd
data/README.md CHANGED
@@ -19,7 +19,8 @@ require "browser"
19
19
 
20
20
  browser = Browser.new(:ua => "some string", :accept_language => "en-us")
21
21
  browser.name # readable browser name
22
- browser.version
22
+ browser.version # major version number
23
+ browser.full_version
23
24
  browser.safari?
24
25
  browser.opera?
25
26
  browser.chrome?
@@ -39,6 +40,10 @@ browser.linux?
39
40
  browser.blackberry?
40
41
  browser.bot?
41
42
  browser.search_engine?
43
+ browser.phantom_js?
44
+ browser.quicktime?
45
+ browser.core_media?
46
+ browser.silk?
42
47
  browser.meta # an array with several attributes
43
48
  browser.to_s # the meta info joined by space
44
49
  ```
data/bots.yml CHANGED
@@ -1,9 +1,12 @@
1
+ 360Spider: "360Spider"
2
+ ADmantX: "ADmantX Platform Semantic Analyzer"
1
3
  AdsBot-Google: "Google Adwords"
2
4
  AhrefsBot: "Ahrefs backlinks research tool"
3
5
  alexa: "Alexa Crawler"
4
6
  Apache-HttpClient: "Java http library"
5
7
  ApacheBench: "ApacheBench (ab)"
6
8
  AppEngine-Google: "Google App Engine"
9
+ Ask Jeeves: "Ask Jeeves"
7
10
  AsyncHttpClient: "Java http and WebSocket client library"
8
11
  awe.sm: "Awe.sm URL expander"
9
12
  Baidu: "Chinese search engine"
@@ -23,6 +26,7 @@ curl: "curl unix CLI http client"
23
26
  developers.google.com/+/web/snippet/: "Google Plus"
24
27
  DigitalPersona Fingerprint Software: "HP Fingerprint scanner"
25
28
  DotBot: "Dot Bot"
29
+ DuckDuckBot: "Duck Duck Go"
26
30
  Embedly: "Embedly"
27
31
  EOAAgent: "EOAAgent"
28
32
  EventMachine HttpClient: "Ruby http library"
@@ -42,9 +46,9 @@ Googlebot: "Google spider"
42
46
  Hatena::Bookmark: "Hatena::Bookmark"
43
47
  heritrix: "heritrix"
44
48
  HTMLParser: "HTMLParser"
45
- HTTP_Request2: "HTTP_Request2"
46
49
  HTTPClient: "HTTPClient"
47
50
  https://developers.google.com/+/web/snippet: "Google+ Snippet Fetcher"
51
+ HTTP_Request2: "HTTP_Request2"
48
52
  HubSpot Connect: "HubSpot Connect"
49
53
  ia_archiver(OS-Wayback): "ia_archiver(OS-Wayback)"
50
54
  iCoreService: "iCoreService"
@@ -52,6 +56,7 @@ InAGist: "URL resolver"
52
56
  Insieve Bot: "Insieve Bot"
53
57
  InsieveBot: "InsieveBot"
54
58
  Instapaper: "Instapaper"
59
+ IstellaBot: "IstellaBot"
55
60
  jack: "jack"
56
61
  Jakarta Commons-HttpClient: "Jakarta Commons-HttpClient"
57
62
  Jakarta Commons: "Jakarta Commons HttpClient"
@@ -67,12 +72,14 @@ libwww-perl: "Perl client-server library loved by script kids"
67
72
  linkdexbot: "Linkdex Bot"
68
73
  LinkedInBot: "LinkedIn"
69
74
  LinksCrawler: "LinksCrawler"
75
+ Linode: "Linode Longview"
70
76
  Lipperhey: "Lipperhey"
71
77
  Livelapbot: "Livelapbot"
72
78
  LoadTimeBot: "Load Time Bot"
73
79
  LongURL: "URL expander service"
74
80
  Lumibot: "Lumibot"
75
81
  lwp-trivial: "Another Perl library loved by script kids"
82
+ magpie-crawler: "magpie-crawler"
76
83
  Mail.RU_Bot: "Mail.ru Bot"
77
84
  Mediapartners-Google: "Google Adsense bot"
78
85
  MetaURI: "MetaURI"
@@ -94,6 +101,8 @@ peerindex: "peerindex"
94
101
  PercolateCrawler: "PercolateCrawler"
95
102
  PhantomJS: "PhantomJS"
96
103
  Pingdom: "Pingdom monitoring"
104
+ Pinterest: "Pinterest"
105
+ publiclibraryarchive.org: "publiclibraryarchive.org"
97
106
  PycURL: "Python http library"
98
107
  Python-httplib2: "Python-httplib2"
99
108
  python-requests: "Python http library"
@@ -109,6 +118,8 @@ Ruby/1.9.3: "Ruby/1.9.3"
109
118
  Ruby: "Ruby"
110
119
  Scrapy: "Scrapy"
111
120
  SemrushBot: "SEO analysis bot"
121
+ SeznamBot: "SeznamBot"
122
+ ShopWiki: "ShopWiki"
112
123
  ShortLinkTranslate: "Link shortener"
113
124
  ShowyouBot: "Showyou iOS app spider"
114
125
  Siege: "Joe Dog Siege"
@@ -119,6 +130,7 @@ spider: "generic web spider"
119
130
  Spinn3r: "Spinn3r aggregator"
120
131
  Test Certificate Info: "C http library?"
121
132
  trendictionbot: "trendiction search"
133
+ TurnitinBot: "TurnitinBot"
122
134
  TweetmemeBot: "TweetMeMe Crawler"
123
135
  Twikle: "Social web search bot"
124
136
  TwitJobSearch: "TwitJobSearch"
@@ -128,12 +140,15 @@ Twurly: "Twurly"
128
140
  Typhoeus: "Typhoeus"
129
141
  UnwindFetch: "Gnip URL expander"
130
142
  UnwindFetchor: "Gnip crawler"
143
+ Vagabondo: "Vagabondo"
131
144
  VB Project: "Visual Basic"
132
145
  vkShare: "VKontake Sharer"
146
+ VoilaBot: "VoilaBot"
133
147
  Webscout: "Webscout"
134
148
  Wget: "wget unix CLI http client"
135
149
  WordPress: "WordPress spider"
136
150
  Xenu Link Sleuth: "Xenu Link Sleuth"
151
+ XoviBot: "XoviBot"
137
152
  YandexBot: "Yandex spider"
138
153
  YandexDirect: "Yandex Direct spider"
139
154
  YandexMetrika: "Yandex Metrika spider"
data/lib/browser.rb CHANGED
@@ -42,9 +42,9 @@ class Browser
42
42
  alias_method :ua=, :user_agent=
43
43
 
44
44
  NAMES = {
45
+ chrome: "Chrome", # Must come before android
45
46
  android: "Android",
46
47
  blackberry: "BlackBerry",
47
- chrome: "Chrome",
48
48
  core_media: "Apple CoreMedia",
49
49
  firefox: "Firefox",
50
50
  ie: "Internet Explorer",
@@ -65,7 +65,8 @@ class Browser
65
65
  }
66
66
 
67
67
  VERSIONS = {
68
- default: %r[(?:Version|MSIE|Firefox|Chrome|CriOS|QuickTime|BlackBerry[^/]+|CoreMedia v|PhantomJS)[/ ]?([a-z0-9.]+)]i,
68
+ chrome: %r[(?:Chrome|CriOS)/([\d.]+)],
69
+ default: %r[(?:Version|MSIE|Firefox|QuickTime|BlackBerry[^/]+|CoreMedia v|PhantomJS)[/ ]?([a-z0-9.]+)]i,
69
70
  opera: %r[(?:Opera/.*? Version/([\d.]+)|Chrome/([\d.]+).*?OPR)],
70
71
  ie: %r[(?:MSIE |Trident/.*?; rv:)([\d.]+)]
71
72
  }
@@ -156,7 +157,7 @@ class Browser
156
157
 
157
158
  # Detect if browser is Safari.
158
159
  def safari?
159
- ua =~ /Safari/ && ua !~ /Chrome|CriOS|PhantomJS/
160
+ ua =~ /Safari/ && ua !~ /Android|Chrome|CriOS|PhantomJS/
160
161
  end
161
162
 
162
163
  # Detect if browser is Firefox.
@@ -5,11 +5,15 @@ class Browser
5
5
  SEARCH_ENGINES = YAML.load_file(root.join("search_engines.yml"))
6
6
 
7
7
  def self.detect_empty_ua!
8
- Browser::Bots::BOTS[''] = 'Generic bot'
8
+ @detect_empty_ua = true
9
+ end
10
+
11
+ def self.detect_empty_ua?
12
+ !!@detect_empty_ua
9
13
  end
10
14
 
11
15
  def bot?
12
- BOTS.any? {|key, _| ua.include?(key) }
16
+ Browser::Bots.detect_empty_ua? && ua.strip == "" || BOTS.any? {|key, _| ua.include?(key) }
13
17
  end
14
18
 
15
19
  def search_engine?
@@ -30,6 +30,11 @@ class Browser
30
30
  ios? && !!(ua =~ /OS 7/)
31
31
  end
32
32
 
33
+ # Detect if is iOS7.
34
+ def ios8?
35
+ ios? && !!(ua =~ /OS 8/)
36
+ end
37
+
33
38
  # Detect if is BlackBerry 4.
34
39
  def blackberry4?
35
40
  blackberry? && !!(ua =~ %r[BlackBerry\d+/4])
@@ -57,7 +62,7 @@ class Browser
57
62
 
58
63
  # Detect if current platform is Macintosh.
59
64
  def mac?
60
- !!(ua =~ /Mac OS X/)
65
+ ua =~ /Mac OS X/ && !ios?
61
66
  end
62
67
 
63
68
  # Detect if current platform is Windows.
@@ -1,7 +1,7 @@
1
1
  class Browser
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 6
4
+ MINOR = 7
5
5
  PATCH = 0
6
6
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
7
  end
data/test/browser_spec.rb CHANGED
@@ -4,6 +4,7 @@ require "spec_helper"
4
4
  describe Browser do
5
5
  before do
6
6
  @browser = Browser.new
7
+ Browser::Bots.instance_variable_set("@detect_empty_ua", false)
7
8
  end
8
9
 
9
10
  it "yields self when block is given" do
@@ -48,7 +49,8 @@ describe Browser do
48
49
  assert @browser.mobile?
49
50
  assert @browser.modern?
50
51
  assert @browser.ios?
51
- assert ! @browser.tablet?
52
+ refute @browser.tablet?
53
+ refute @browser.mac?
52
54
  assert_equal "3.0", @browser.full_version
53
55
  assert_equal "3", @browser.version
54
56
  end
@@ -74,7 +76,8 @@ describe Browser do
74
76
  assert @browser.mobile?
75
77
  assert @browser.modern?
76
78
  assert @browser.ios?
77
- assert ! @browser.tablet?
79
+ refute @browser.tablet?
80
+ refute @browser.mac?
78
81
  assert_equal "3.0", @browser.full_version
79
82
  assert_equal "3", @browser.version
80
83
  end
@@ -89,7 +92,8 @@ describe Browser do
89
92
  assert @browser.modern?
90
93
  assert @browser.ios?
91
94
  assert @browser.tablet?
92
- assert ! @browser.mobile?
95
+ refute @browser.mobile?
96
+ refute @browser.mac?
93
97
  assert_equal "4.0.4", @browser.full_version
94
98
  assert_equal "4", @browser.version
95
99
  end
@@ -98,6 +102,7 @@ describe Browser do
98
102
  @browser.ua = $ua["IOS4"]
99
103
  assert @browser.ios?
100
104
  assert @browser.ios4?
105
+ refute @browser.mac?
101
106
  end
102
107
 
103
108
 
@@ -105,18 +110,28 @@ describe Browser do
105
110
  @browser.ua = $ua["IOS5"]
106
111
  assert @browser.ios?
107
112
  assert @browser.ios5?
113
+ refute @browser.mac?
108
114
  end
109
115
 
110
116
  it "detects ios6" do
111
117
  @browser.ua = $ua["IOS6"]
112
118
  assert @browser.ios?
113
119
  assert @browser.ios6?
120
+ refute @browser.mac?
114
121
  end
115
122
 
116
123
  it "detects ios7" do
117
124
  @browser.ua = $ua["IOS7"]
118
125
  assert @browser.ios?
119
126
  assert @browser.ios7?
127
+ refute @browser.mac?
128
+ end
129
+
130
+ it "detects ios8" do
131
+ @browser.ua = $ua["IOS8"]
132
+ assert @browser.ios?
133
+ assert @browser.ios8?
134
+ refute @browser.mac?
120
135
  end
121
136
 
122
137
  it "detects ie6" do
@@ -125,7 +140,7 @@ describe Browser do
125
140
  assert_equal "Internet Explorer", @browser.name
126
141
  assert @browser.ie?
127
142
  assert @browser.ie6?
128
- assert ! @browser.modern?
143
+ refute @browser.modern?
129
144
  assert_equal "6.0", @browser.full_version
130
145
  assert_equal "6", @browser.version
131
146
  end
@@ -136,7 +151,7 @@ describe Browser do
136
151
  assert_equal "Internet Explorer", @browser.name
137
152
  assert @browser.ie?
138
153
  assert @browser.ie7?
139
- assert ! @browser.modern?
154
+ refute @browser.modern?
140
155
  assert_equal "7.0", @browser.full_version
141
156
  assert_equal "7", @browser.version
142
157
  end
@@ -147,8 +162,8 @@ describe Browser do
147
162
  assert_equal "Internet Explorer", @browser.name
148
163
  assert @browser.ie?
149
164
  assert @browser.ie8?
150
- assert ! @browser.modern?
151
- assert ! @browser.compatibility_view?
165
+ refute @browser.modern?
166
+ refute @browser.compatibility_view?
152
167
  assert_equal "8.0", @browser.full_version
153
168
  assert_equal "8", @browser.version
154
169
  end
@@ -159,8 +174,8 @@ describe Browser do
159
174
  assert_equal "Internet Explorer", @browser.name
160
175
  assert @browser.ie?
161
176
  assert @browser.ie7?
162
- assert ! @browser.ie8?
163
- assert ! @browser.modern?
177
+ refute @browser.ie8?
178
+ refute @browser.modern?
164
179
  assert @browser.compatibility_view?
165
180
  assert_equal "7.0", @browser.full_version
166
181
  assert_equal "7", @browser.version
@@ -173,7 +188,7 @@ describe Browser do
173
188
  assert @browser.ie?
174
189
  assert @browser.ie9?
175
190
  assert @browser.modern?
176
- assert ! @browser.compatibility_view?
191
+ refute @browser.compatibility_view?
177
192
  assert_equal "9.0", @browser.full_version
178
193
  assert_equal "9", @browser.version
179
194
  end
@@ -184,8 +199,8 @@ describe Browser do
184
199
  assert_equal "Internet Explorer", @browser.name
185
200
  assert @browser.ie?
186
201
  assert @browser.ie7?
187
- assert ! @browser.ie9?
188
- assert ! @browser.modern?
202
+ refute @browser.ie9?
203
+ refute @browser.modern?
189
204
  assert @browser.compatibility_view?
190
205
  assert_equal "7.0", @browser.full_version
191
206
  assert_equal "7", @browser.version
@@ -198,7 +213,7 @@ describe Browser do
198
213
  assert @browser.ie?
199
214
  assert @browser.ie10?
200
215
  assert @browser.modern?
201
- assert ! @browser.compatibility_view?
216
+ refute @browser.compatibility_view?
202
217
  assert_equal "10.0", @browser.full_version
203
218
  assert_equal "10", @browser.version
204
219
  end
@@ -209,8 +224,8 @@ describe Browser do
209
224
  assert_equal "Internet Explorer", @browser.name
210
225
  assert @browser.ie?
211
226
  assert @browser.ie7?
212
- assert ! @browser.ie10?
213
- assert ! @browser.modern?
227
+ refute @browser.ie10?
228
+ refute @browser.modern?
214
229
  assert @browser.compatibility_view?
215
230
  assert_equal "7.0", @browser.full_version
216
231
  assert_equal "7", @browser.version
@@ -223,7 +238,7 @@ describe Browser do
223
238
  assert @browser.ie?
224
239
  assert @browser.ie11?
225
240
  assert @browser.modern?
226
- assert ! @browser.compatibility_view?
241
+ refute @browser.compatibility_view?
227
242
  assert_equal "11.0", @browser.full_version
228
243
  assert_equal "11", @browser.version
229
244
  end
@@ -233,7 +248,7 @@ describe Browser do
233
248
 
234
249
  assert_equal "Opera", @browser.name
235
250
  assert @browser.opera?
236
- assert ! @browser.modern?
251
+ refute @browser.modern?
237
252
  assert_equal "11.64", @browser.full_version
238
253
  assert_equal "11", @browser.version
239
254
  end
@@ -246,7 +261,7 @@ describe Browser do
246
261
  assert @browser.opera?
247
262
  assert @browser.webkit?
248
263
  assert @browser.modern?
249
- assert ! @browser.chrome?
264
+ refute @browser.chrome?
250
265
  assert_equal "28.0.1500.37", @browser.full_version
251
266
  assert_equal "28", @browser.version
252
267
  end
@@ -256,7 +271,7 @@ describe Browser do
256
271
 
257
272
  assert_equal "Firefox", @browser.name
258
273
  assert @browser.firefox?
259
- assert ! @browser.modern?
274
+ refute @browser.modern?
260
275
  assert_equal "3.8", @browser.full_version
261
276
  assert_equal "3", @browser.version
262
277
  end
@@ -288,7 +303,7 @@ describe Browser do
288
303
 
289
304
  assert_equal "Chrome", @browser.name
290
305
  assert @browser.chrome?
291
- assert ! @browser.safari?
306
+ refute @browser.safari?
292
307
  assert @browser.webkit?
293
308
  assert @browser.modern?
294
309
  assert_equal "5.0.375.99", @browser.full_version
@@ -300,22 +315,35 @@ describe Browser do
300
315
 
301
316
  assert_equal "Chrome", @browser.name
302
317
  assert @browser.chrome?
303
- assert ! @browser.safari?
318
+ refute @browser.safari?
304
319
  assert @browser.webkit?
305
320
  assert @browser.modern?
306
321
  assert_equal "19.0.1084.60", @browser.full_version
307
322
  assert_equal "19", @browser.version
308
323
  end
309
324
 
325
+ it "detects samsung chrome" do
326
+ @browser.ua = $ua["SAMSUNG_CHROME"]
327
+
328
+ assert_equal "Chrome", @browser.name
329
+ assert @browser.chrome?
330
+ assert @browser.android?
331
+ refute @browser.safari?
332
+ assert @browser.webkit?
333
+ assert @browser.modern?
334
+ assert_equal "28.0.1500.94", @browser.full_version
335
+ assert_equal "28", @browser.version
336
+ end
337
+
310
338
  it "detects android" do
311
339
  @browser.ua = $ua["ANDROID"]
312
340
 
313
341
  assert_equal "Android", @browser.name
314
342
  assert @browser.android?
315
- assert @browser.safari?
343
+ refute @browser.safari?
316
344
  assert @browser.webkit?
317
345
  assert @browser.mobile?
318
- assert ! @browser.tablet?
346
+ refute @browser.tablet?
319
347
  assert @browser.modern?
320
348
  assert_equal "3.1.2", @browser.full_version
321
349
  assert_equal "3", @browser.version
@@ -326,9 +354,9 @@ describe Browser do
326
354
 
327
355
  assert_equal "Android", @browser.name
328
356
  assert @browser.android?
329
- assert @browser.safari?
357
+ refute @browser.safari?
330
358
  assert @browser.webkit?
331
- assert ! @browser.mobile?
359
+ refute @browser.mobile?
332
360
  assert @browser.tablet?
333
361
  assert @browser.modern?
334
362
  assert_equal "4.0", @browser.full_version
@@ -341,7 +369,7 @@ describe Browser do
341
369
  assert_equal "Internet Explorer", @browser.name
342
370
  assert @browser.surface?
343
371
  assert @browser.ie?
344
- assert ! @browser.mobile?
372
+ refute @browser.mobile?
345
373
  assert @browser.tablet?
346
374
  assert @browser.modern?
347
375
  assert_equal "10.0", @browser.full_version
@@ -353,9 +381,9 @@ describe Browser do
353
381
 
354
382
  assert_equal "BlackBerry", @browser.name
355
383
  assert @browser.blackberry?
356
- assert ! @browser.tablet?
384
+ refute @browser.tablet?
357
385
  assert @browser.mobile?
358
- assert ! @browser.modern?
386
+ refute @browser.modern?
359
387
  assert_equal "4.1.0", @browser.full_version
360
388
  assert_equal "4", @browser.version
361
389
  end
@@ -365,9 +393,9 @@ describe Browser do
365
393
 
366
394
  assert_equal "BlackBerry", @browser.name
367
395
  assert @browser.blackberry4?
368
- assert ! @browser.tablet?
396
+ refute @browser.tablet?
369
397
  assert @browser.mobile?
370
- assert ! @browser.modern?
398
+ refute @browser.modern?
371
399
  assert_equal "4.2.1", @browser.full_version
372
400
  assert_equal "4", @browser.version
373
401
  end
@@ -377,9 +405,9 @@ describe Browser do
377
405
 
378
406
  assert_equal "BlackBerry", @browser.name
379
407
  assert @browser.blackberry5?
380
- assert ! @browser.tablet?
408
+ refute @browser.tablet?
381
409
  assert @browser.mobile?
382
- assert ! @browser.modern?
410
+ refute @browser.modern?
383
411
  assert_equal "5.0.0.93", @browser.full_version
384
412
  assert_equal "5", @browser.version
385
413
  end
@@ -389,7 +417,7 @@ describe Browser do
389
417
 
390
418
  assert_equal "BlackBerry", @browser.name
391
419
  assert @browser.blackberry6?
392
- assert ! @browser.tablet?
420
+ refute @browser.tablet?
393
421
  assert @browser.mobile?
394
422
  assert @browser.modern?
395
423
  assert_equal "534.11", @browser.full_version
@@ -401,7 +429,7 @@ describe Browser do
401
429
 
402
430
  assert_equal "BlackBerry", @browser.name
403
431
  assert @browser.blackberry7?
404
- assert ! @browser.tablet?
432
+ refute @browser.tablet?
405
433
  assert @browser.mobile?
406
434
  assert @browser.modern?
407
435
  assert_equal "534.11", @browser.full_version
@@ -413,7 +441,7 @@ describe Browser do
413
441
 
414
442
  assert_equal "Safari", @browser.name
415
443
  assert @browser.blackberry10?
416
- assert ! @browser.tablet?
444
+ refute @browser.tablet?
417
445
  assert @browser.mobile?
418
446
  assert @browser.modern?
419
447
  assert_equal "10.0.9.1675", @browser.full_version
@@ -443,8 +471,8 @@ describe Browser do
443
471
 
444
472
  assert_equal "PhantomJS", @browser.name
445
473
  assert @browser.phantom_js?
446
- assert ! @browser.tablet?
447
- assert ! @browser.mobile?
474
+ refute @browser.tablet?
475
+ refute @browser.mobile?
448
476
  assert @browser.modern?
449
477
  assert_equal "1.9.0", @browser.full_version
450
478
  assert_equal "1", @browser.version
@@ -469,11 +497,11 @@ describe Browser do
469
497
  it "detects other mobiles" do
470
498
  @browser.ua = "Symbian OS"
471
499
  assert @browser.mobile?
472
- assert ! @browser.tablet?
500
+ refute @browser.tablet?
473
501
 
474
502
  @browser.ua = "MIDP-2.0"
475
503
  assert @browser.mobile?
476
- assert ! @browser.tablet?
504
+ refute @browser.tablet?
477
505
  end
478
506
 
479
507
  it "detects windows mobile" do
@@ -482,8 +510,8 @@ describe Browser do
482
510
  assert @browser.mobile?
483
511
  assert @browser.windows?
484
512
  assert @browser.windows_mobile?
485
- assert ! @browser.windows_phone?
486
- assert ! @browser.tablet?
513
+ refute @browser.windows_phone?
514
+ refute @browser.tablet?
487
515
  end
488
516
 
489
517
  it "returns a zero version" do
@@ -516,7 +544,6 @@ describe Browser do
516
544
  assert meta.include?("ios")
517
545
  assert meta.include?("safari")
518
546
  assert meta.include?("safari3")
519
- assert meta.include?("mac")
520
547
  assert meta.include?("modern")
521
548
  assert meta.include?("mobile")
522
549
  end
@@ -622,7 +649,7 @@ describe Browser do
622
649
 
623
650
  assert @browser.android?
624
651
  assert @browser.tablet?
625
- assert ! @browser.mobile?
652
+ refute @browser.mobile?
626
653
  end
627
654
 
628
655
  it "detects nexus tablet" do
@@ -630,15 +657,15 @@ describe Browser do
630
657
 
631
658
  assert @browser.android?
632
659
  assert @browser.tablet?
633
- assert ! @browser.mobile?
660
+ refute @browser.mobile?
634
661
  end
635
662
 
636
663
  it "detects blackberry playbook tablet" do
637
664
  @browser.ua = $ua["PLAYBOOK"]
638
665
 
639
- assert ! @browser.android?
666
+ refute @browser.android?
640
667
  assert @browser.tablet?
641
- assert ! @browser.mobile?
668
+ refute @browser.mobile?
642
669
 
643
670
  assert_equal "7.2.1.0", @browser.full_version
644
671
  assert_equal "7", @browser.version
@@ -648,7 +675,7 @@ describe Browser do
648
675
  @browser.ua = $ua["OPERA_MINI"]
649
676
 
650
677
  assert @browser.opera_mini?
651
- assert ! @browser.tablet?
678
+ refute @browser.tablet?
652
679
  assert @browser.mobile?
653
680
  end
654
681
 
@@ -656,7 +683,7 @@ describe Browser do
656
683
  @browser.ua = $ua["OPERA_MOBI"]
657
684
 
658
685
  assert @browser.opera?
659
- assert ! @browser.tablet?
686
+ refute @browser.tablet?
660
687
  assert @browser.mobile?
661
688
  end
662
689
 
@@ -667,8 +694,8 @@ describe Browser do
667
694
  assert_equal "7", @browser.version
668
695
  assert @browser.mobile?
669
696
  assert @browser.windows_phone?
670
- assert ! @browser.windows_mobile?
671
- assert ! @browser.tablet?
697
+ refute @browser.windows_mobile?
698
+ refute @browser.tablet?
672
699
  end
673
700
 
674
701
  it "detects windows phone 8" do
@@ -678,8 +705,8 @@ describe Browser do
678
705
  assert_equal "10", @browser.version
679
706
  assert @browser.mobile?
680
707
  assert @browser.windows_phone?
681
- assert ! @browser.windows_mobile?
682
- assert ! @browser.tablet?
708
+ refute @browser.windows_mobile?
709
+ refute @browser.tablet?
683
710
  end
684
711
 
685
712
  it "detects windows mobile" do
@@ -689,8 +716,8 @@ describe Browser do
689
716
  assert_equal "10", @browser.version
690
717
  assert @browser.mobile?
691
718
  assert @browser.windows_phone?
692
- assert ! @browser.windows_mobile?
693
- assert ! @browser.tablet?
719
+ refute @browser.windows_mobile?
720
+ refute @browser.tablet?
694
721
  end
695
722
 
696
723
  it "detects windows x64" do
@@ -705,8 +732,8 @@ describe Browser do
705
732
  assert @browser.ie?
706
733
  assert @browser.ie11?
707
734
  assert @browser.modern?
708
- assert ! @browser.compatibility_view?
709
- assert ! @browser.windows_rt?
735
+ refute @browser.compatibility_view?
736
+ refute @browser.windows_rt?
710
737
  assert @browser.windows_touchscreen_desktop?
711
738
  assert @browser.windows8?
712
739
  assert_equal "11.0", @browser.full_version
@@ -734,7 +761,7 @@ describe Browser do
734
761
  assert @browser.kindle?
735
762
  assert @browser.webkit?
736
763
  assert @browser.modern?
737
- assert ! @browser.mobile?
764
+ refute @browser.mobile?
738
765
  end
739
766
 
740
767
  it "detects kindle fire hd mobile" do
@@ -751,14 +778,14 @@ describe Browser do
751
778
  @browser.ua = $ua["NOOK"]
752
779
 
753
780
  assert @browser.tablet?
754
- assert ! @browser.mobile?
781
+ refute @browser.mobile?
755
782
  end
756
783
 
757
784
  it "detects samsung" do
758
785
  @browser.ua = $ua["SAMSUNG"]
759
786
 
760
787
  assert @browser.tablet?
761
- assert ! @browser.mobile?
788
+ refute @browser.mobile?
762
789
  end
763
790
 
764
791
  it "detects nintendo wii" do
@@ -831,19 +858,24 @@ describe Browser do
831
858
  end
832
859
 
833
860
  @browser.ua = $ua["CHROME"]
834
- assert ! @browser.bot?
861
+ refute @browser.bot?
835
862
  end
836
863
 
837
864
  it "doesn't consider empty UA as bot" do
838
865
  @browser.ua = ''
839
- assert ! @browser.bot?
866
+ refute @browser.bot?
840
867
  end
841
868
 
842
869
  it "allows setting empty string as bots" do
843
870
  Browser::Bots.detect_empty_ua!
844
871
  @browser.ua = ''
845
872
  assert @browser.bot?
846
- Browser::Bots::BOTS.delete('')
873
+ end
874
+
875
+ it "doesn't consider mozilla as a bot when considerint empty UA" do
876
+ Browser::Bots.detect_empty_ua!
877
+ @browser.ua = "Mozilla"
878
+ refute @browser.bot?
847
879
  end
848
880
 
849
881
  it "detects chrome os" do
data/test/ua.yml CHANGED
@@ -37,6 +37,7 @@ XOOM: "Mozilla/5.0 (Linux; U; Android 3.0; en-us; Xoom Build/HRI39) AppleWebKit/
37
37
  NEXUS_TABLET: "Mozilla/5.0 (Linux; Android 4.1.1; Nexus 7 Build/JRO03D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Safari/535.19"
38
38
  NOOK: "Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; NOOK BNTV250A Build/GINGERBREAD 1.4.3) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Safari/533.1"
39
39
  SAMSUNG: "Mozilla/5.0 (Linux; U; Android 4.0.4; en-us; SAMSUNG-SGH-I497 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30"
40
+ SAMSUNG_CHROME: "Mozilla/5.0 (Linux; Android 4.4.2; en-gb; SAMSUNG GT-I9195/I9195XXUCNEA Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrome/28.0.1500.94 Mobile Safari/537.36"
40
41
  OPERA_MINI: "Opera/9.80 (Android; Opera Mini/7.029952/28.2359;u; fr) Presto/2.8.119 Version/11.10"
41
42
  OPERA_MOBI: "Opera/9.8 (Android 2.3.5; Linux; Opera Mobi/ADR-1205181138; U; en) Presto/2.10.254 Version/12.00"
42
43
  WINDOWS_PHONE: "Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; DELL; Venue Pro)"
@@ -54,6 +55,7 @@ IOS4: "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebK
54
55
  IOS5: "Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3"
55
56
  IOS6: "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25"
56
57
  IOS7: "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53"
58
+ IOS8: "Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12A365 Safari/600.1.4"
57
59
  PLAYBOOK: "Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML, like Gecko) Version/7.2.1.0 Safari/536.2+"
58
60
  NINTENDO_WII: "Opera/9.00 (Nintendo Wii; U; ; 1309-9; en)"
59
61
  NINTENDO_WIIU: "Mozilla/5.0 (Nintendo WiiU) AppleWebKit/534.52 (KHTML, like Gecko) NX/2.1.0.8.23 NintendoBrowser/1.1.0.7579.EU"
@@ -77,3 +79,4 @@ YAHOO_SLURP: "Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/
77
79
  ASK: "Mozilla/2.0 (compatible; Ask Jeeves/Teoma; +http://sp.ask.com/docs/about/tech_crawling.html)"
78
80
  BINGBOT: "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)"
79
81
  DUCKDUCKGO: "DuckDuckBot/1.0; (+http://duckduckgo.com/duckduckbot.html)"
82
+ ANDROID_WITH_SAFARI: 'Mozilla/5.0 (Linux; U; Android 4.3; en-us; SCH-I535 Build/JSS15J) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30'
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: 0.6.0
4
+ version: 0.7.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: 2014-06-06 00:00:00.000000000 Z
11
+ date: 2014-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler