browser 0.8.0 → 0.9.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: bf057ec168032438df5564a7a443ae8856607637
4
- data.tar.gz: 85337b0813ccc98e8d6970e2470b7ed9b0413abc
3
+ metadata.gz: 37252f7cb661e8d14c83014f166e0a278f3432a0
4
+ data.tar.gz: 1b5dc1768052be44b9861ce4937fd16e28f66688
5
5
  SHA512:
6
- metadata.gz: 0d8f6c9fdcbbee23131bab3aa4dc79f84413f1ff58a5e750a113293a06782fd01305f7da5a0e7287c9cf2944d6fdfbfb699016cc3e926f12a37e8514e21207af
7
- data.tar.gz: 6dc8e034081314899bc389bce63f05fe1e1394d1c4f80f13d6720af9b5d3eb3d9864f9b9c9308b4c9344075bf29d81c92fb8a3c8eeaad57bf0bf5a38e1cebf53
6
+ metadata.gz: 38e895ab3b7ee2a75526af927fcebfe87e75320680d8663e43c614b271e1ddc6c219f0e561cede2463672b351d4587cbe0ba35e8fa697dee26ed4cf1b7cf2130
7
+ data.tar.gz: e3b27b51d5f4815289137fd63c1333797a7e83b6582fe57d428c3fd854f8094a96de6102fbb7be1080a871365eea17135650be99ca1b64ff2c47d3922e83de1e
@@ -0,0 +1,90 @@
1
+ ClassLength:
2
+ Enabled: false
3
+
4
+ CyclomaticComplexity:
5
+ Enabled: false
6
+
7
+ Documentation:
8
+ Enabled: false
9
+
10
+ Encoding:
11
+ Enabled: false
12
+
13
+ FileName:
14
+ Enabled: false
15
+
16
+ IfUnlessModifier:
17
+ Enabled: false
18
+
19
+ MethodLength:
20
+ Enabled: false
21
+
22
+ ModuleFunction:
23
+ Enabled: false
24
+
25
+ OneLineConditional:
26
+ Enabled: false
27
+
28
+ ParameterLists:
29
+ Enabled: false
30
+
31
+ Proc:
32
+ Enabled: false
33
+
34
+ SingleLineBlockParams:
35
+ Enabled: false
36
+
37
+ VariableInterpolation:
38
+ Enabled: false
39
+
40
+ TrailingComma:
41
+ Enabled: false
42
+
43
+ WhileUntilModifier:
44
+ Enabled: false
45
+
46
+ PredicateName:
47
+ NamePrefixBlacklist:
48
+ - is_
49
+
50
+ StringLiterals:
51
+ EnforcedStyle: double_quotes
52
+ SupportedStyles:
53
+ - single_quotes
54
+ - double_quotes
55
+
56
+ DotPosition:
57
+ EnforcedStyle: leading
58
+
59
+ SpaceBeforeBlockBraces:
60
+ EnforcedStyle: space
61
+
62
+ SpaceInsideBlockBraces:
63
+ EnforcedStyle: no_space
64
+
65
+ DoubleNegation:
66
+ Enabled: false
67
+
68
+ SpaceInsideBlockBraces:
69
+ SpaceBeforeBlockParameters: false
70
+
71
+ LineLength:
72
+ Max: 130
73
+
74
+ RegexpLiteral:
75
+ MaxSlashes: 0
76
+
77
+ SpaceInsideHashLiteralBraces:
78
+ Enabled: false
79
+
80
+ PercentLiteralDelimiters:
81
+ PreferredDelimiters:
82
+ '%': '[]'
83
+ '%i': '[]'
84
+ '%q': '[]'
85
+ '%Q': '[]'
86
+ '%r': '[]'
87
+ '%s': '[]'
88
+ '%w': '[]'
89
+ '%W': '[]'
90
+ '%x': '[]'
@@ -1,8 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
4
- - 2.0.0
5
- - 2.1.4
3
+ - '2.2'
4
+ - '2.1'
5
+ - '2.0'
6
6
  gemfile:
7
7
  - Gemfile
8
8
  - gemfiles/rails3.gemfile
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![Travis-CI](https://travis-ci.org/fnando/browser.png)](https://travis-ci.org/fnando/browser)
4
4
  [![CodeClimate](https://codeclimate.com/github/fnando/browser.png)](https://codeclimate.com/github/fnando/browser)
5
+ [![Gem Version](https://badge.fury.io/rb/browser.svg)](http://badge.fury.io/rb/browser)
5
6
 
6
7
  Do some browser detection with Ruby. Includes ActionController integration.
7
8
 
@@ -31,6 +32,7 @@ browser.console?
31
32
  browser.firefox?
32
33
  browser.ie?
33
34
  browser.ie6? # this goes up to 11
35
+ browser.edge? # Newest MS browser
34
36
  browser.modern? # Webkit, Firefox 17+, IE 9+ and Opera 12+
35
37
  browser.platform # return :mac, :windows, :linux or :other
36
38
  browser.mac?
@@ -61,7 +63,7 @@ The current rules that define a modern browser are pretty loose:
61
63
  * Firefox Tablet 14+
62
64
  * Opera 12+
63
65
 
64
- You can define your your rules. A rule must be a proc/lambda or any object that implements the method === and accepts the browser object. To redefine all rules, clear the existing rules before adding your own.
66
+ You can define your own rules. A rule must be a proc/lambda or any object that implements the method === and accepts the browser object. To redefine all rules, clear the existing rules before adding your own.
65
67
 
66
68
  ```ruby
67
69
  # Only Chrome Canary is considered modern.
@@ -121,6 +123,13 @@ Rails.configuration.middleware.use Browser::Middleware do
121
123
  end
122
124
  ```
123
125
 
126
+ If you need acccess to the `Rack::Request` object (e.g. to exclude a path), you can do so with `request`.
127
+ ```ruby
128
+ Rails.configuration.middleware.use Browser::Middleware do
129
+ redirect_to upgrade_path unless browser.modern? || request.env['PATH_INFO'] == '/exclude_me'
130
+ end
131
+ ```
132
+
124
133
  ## Maintainer
125
134
 
126
135
  * Nando Vieira - http://nandovieira.com.br
data/bots.yml CHANGED
@@ -7,6 +7,7 @@ alexa: "Alexa Crawler"
7
7
  Apache-HttpClient: "Java http library"
8
8
  ApacheBench: "ApacheBench (ab)"
9
9
  AppEngine-Google: "Google App Engine"
10
+ Applebot: "Apple Bot"
10
11
  Ask Jeeves: "Ask Jeeves"
11
12
  AsyncHttpClient: "Java http and WebSocket client library"
12
13
  awe.sm: "Awe.sm URL expander"
@@ -14,6 +15,7 @@ Baidu: "baidu"
14
15
  Baiduspider: "Chinese search engine"
15
16
  bingbot: "Microsoft bing bot"
16
17
  bitlybot: "bit.ly bot"
18
+ BLEXBot: "webmeup-crawler.com"
17
19
  bot@linkfluence.net: "Linkfluence bot"
18
20
  BuiBui-CheckBot: "email: buibui[at]dadapro[dot]com"
19
21
  Butterfly: "Topsy Labs"
@@ -35,7 +37,8 @@ EventMachine HttpClient: "Ruby http library"
35
37
  EvriNid: "Evri bot"
36
38
  Exabot: "Exalead's bot"
37
39
  ExaleadCloudView: "ExaleadCloudView"
38
- facebookexternalhit: "facebook bot"
40
+ facebookexternalhit: "Facebook Bot"
41
+ Facebot: "Facebook Bot"
39
42
  FeedBurner: "RSS bot"
40
43
  Feedfetcher-Google: "Google Feedfetcher"
41
44
  FlipboardProxy: "FlipboardProxy"
@@ -44,6 +47,7 @@ getprismatic.com: "getprismatic.com"
44
47
  Gigabot: "Gigabot spider"
45
48
  Go http package: "Go http library"
46
49
  Google Web Preview: "Google Instant Previews crawler"
50
+ Google Page Speed Insights: "Google Page Speed Insights"
47
51
  Googlebot: "Google spider"
48
52
  Hatena::Bookmark: "Hatena::Bookmark"
49
53
  heritrix: "heritrix"
@@ -85,6 +89,7 @@ lwp-trivial: "Another Perl library loved by script kids"
85
89
  magpie-crawler: "magpie-crawler"
86
90
  Mail.RU_Bot: "Mail.ru Bot"
87
91
  Mediapartners-Google: "Google Adsense bot"
92
+ MegaIndex.ru: "Mozilla/5.0 (compatible; MegaIndex.ru/2.0; +https://www.megaindex.ru/?tab=linkAnalyze)"
88
93
  MetaURI: "MetaURI"
89
94
  MetaURI: "URI meta information extractor bot"
90
95
  MFE_expand: "Mcafee spider"
@@ -112,6 +117,7 @@ Python-httplib2: "Python-httplib2"
112
117
  python-requests: "Python http library"
113
118
  python-requests: "python-requests"
114
119
  Python-urllib: "Python http library"
120
+ QuerySeeker: "QuerySeekerSpider ( http://queryseeker.com/bot.html )"
115
121
  QuickLook: "QuickLook"
116
122
  Readability: "Readability"
117
123
  RebelMouse: "RebelMouse"
@@ -129,6 +135,7 @@ ShortLinkTranslate: "Link shortener"
129
135
  ShowyouBot: "Showyou iOS app spider"
130
136
  Siege: "Joe Dog Siege"
131
137
  SiteUptime: "Site monitoring services"
138
+ Slack: "Slackbot-LinkExpanding"
132
139
  Slurp: "Yahoo spider"
133
140
  Sogou: "Chinese search engine"
134
141
  spider: "generic web spider"
@@ -153,6 +160,7 @@ VoilaBot: "VoilaBot"
153
160
  Webscout: "Webscout"
154
161
  Wget: "wget unix CLI http client"
155
162
  WordPress: "WordPress spider"
163
+ Wormly: "WormlyBot"
156
164
  Xenu Link Sleuth: "Xenu Link Sleuth"
157
165
  XoviBot: "XoviBot"
158
166
  YandexBot: "Yandex spider"
@@ -162,3 +170,4 @@ YOURLS: "YOURLS"
162
170
  zelist.ro: "feed parser"
163
171
  ZIBB: "ZIBB spider"
164
172
  ZyBorg: "Zyborg? Hmmm...."
173
+ StructuredDataTestingTool: 'Google-StructuredDataTestingTool'
@@ -11,6 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.homepage = "http://github.com/fnando/browser"
12
12
  s.summary = "Do some browser detection with Ruby."
13
13
  s.description = s.summary
14
+ s.license = 'MIT'
14
15
 
15
16
  s.files = `git ls-files`.split("\n")
16
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -22,4 +23,5 @@ Gem::Specification.new do |s|
22
23
  s.add_development_dependency "rails"
23
24
  s.add_development_dependency "rack-test"
24
25
  s.add_development_dependency "minitest"
26
+ s.add_development_dependency "minitest-utils"
25
27
  end
@@ -42,12 +42,13 @@ class Browser
42
42
  alias_method :ua=, :user_agent=
43
43
 
44
44
  NAMES = {
45
- ie: "Internet Explorer", # Must come before android
46
- chrome: "Chrome", # Must come before android
45
+ edge: "Microsoft Edge", # Must come before everything
46
+ ie: "Internet Explorer", # Must come before android
47
+ chrome: "Chrome", # Must come before android
48
+ firefox: "Firefox", # Must come before android
47
49
  android: "Android",
48
50
  blackberry: "BlackBerry",
49
51
  core_media: "Apple CoreMedia",
50
- firefox: "Firefox",
51
52
  ipad: "iPad",
52
53
  iphone: "iPhone",
53
54
  ipod: "iPod Touch",
@@ -65,6 +66,7 @@ class Browser
65
66
  }
66
67
 
67
68
  VERSIONS = {
69
+ edge: %r[Edge/([\d.]+)],
68
70
  chrome: %r[(?:Chrome|CriOS)/([\d.]+)],
69
71
  default: %r[(?:Version|MSIE|Firefox|QuickTime|BlackBerry[^/]+|CoreMedia v|PhantomJS|AdobeAIR)[/ ]?([a-z0-9.]+)]i,
70
72
  opera: %r[(?:Opera/.*? Version/([\d.]+)|Chrome/.*?OPR/([\d.]+))],
@@ -137,7 +139,7 @@ class Browser
137
139
 
138
140
  # Detect if browser is WebKit-based.
139
141
  def webkit?
140
- !!(ua =~ /AppleWebKit/i)
142
+ ua =~ /AppleWebKit/i && !edge?
141
143
  end
142
144
 
143
145
  # Detect if browser is QuickTime
@@ -171,7 +173,12 @@ class Browser
171
173
 
172
174
  # Detect if browser is Chrome.
173
175
  def chrome?
174
- !!(ua =~ /Chrome|CriOS/) && !opera?
176
+ ua =~ /Chrome|CriOS/ && !opera? && !edge?
177
+ end
178
+
179
+ # Detect if browser is Microsoft Edge.
180
+ def edge?
181
+ !!(ua =~ /Windows.*?\bEdge\/\d+/)
175
182
  end
176
183
 
177
184
  # Detect if browser is Opera.
@@ -19,7 +19,7 @@ class Browser
19
19
  def bot_name
20
20
  return unless bot?
21
21
  return "Generic Bot" if bot_with_empty_ua?
22
- BOTS.find {|key, description| ua.include?(key) }.first
22
+ BOTS.find {|key, _| ua.include?(key) }.first
23
23
  end
24
24
 
25
25
  def search_engine?
@@ -26,6 +26,7 @@ class Browser
26
26
  def detect_mobile?
27
27
  !!(
28
28
  psp? ||
29
+ /zunewp7/i.match(ua) ||
29
30
  /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.match(ua) ||
30
31
  /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.match(ua[0..3])
31
32
  )
@@ -70,17 +70,33 @@ class Browser
70
70
  !!(ua =~ /Windows/)
71
71
  end
72
72
 
73
+ ## More info here => http://msdn.microsoft.com/fr-FR/library/ms537503.aspx#PltToken
74
+ def windows_xp?
75
+ windows? && !!(ua =~ /Windows NT 5.1/)
76
+ end
77
+
78
+ def windows_vista?
79
+ windows? && !!(ua =~ /Windows NT 6.0/)
80
+ end
81
+
82
+ def windows7?
83
+ windows? && !!(ua =~ /Windows NT 6.1/)
84
+ end
85
+
73
86
  def windows8?
74
87
  windows? && !!(ua =~ /Windows NT 6.[2-3]/)
75
88
  end
76
89
 
77
- def windows_rt?
78
- windows8? && !!(ua =~ /ARM/)
90
+ def windows8_1?
91
+ windows? && !!(ua =~ /Windows NT 6\.3/)
79
92
  end
80
93
 
81
- # Detect if current platform is Linux flavor.
82
- def linux?
83
- !!(ua =~ /Linux/)
94
+ def windows10?
95
+ windows? && !!(ua =~ /Windows NT 10/)
96
+ end
97
+
98
+ def windows_rt?
99
+ windows8? && !!(ua =~ /ARM/)
84
100
  end
85
101
 
86
102
  # Detect if current platform is Windows Mobile.
@@ -98,6 +114,19 @@ class Browser
98
114
  windows? && !!(ua =~ /(Win64|x64)/) && !!(ua =~ /x64/)
99
115
  end
100
116
 
117
+ def windows_wow64?
118
+ windows? && !!(ua =~ /WOW64/i)
119
+ end
120
+
121
+ def windows_x64_inclusive?
122
+ windows_x64? || windows_wow64?
123
+ end
124
+
125
+ # Detect if current platform is Linux flavor.
126
+ def linux?
127
+ !!(ua =~ /Linux/)
128
+ end
129
+
101
130
  # Detect if current platform is ChromeOS
102
131
  def chrome_os?
103
132
  !!(ua =~ /CrOS/)
@@ -1,7 +1,7 @@
1
1
  class Browser
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 8
4
+ MINOR = 9
5
5
  PATCH = 0
6
6
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
7
  end
@@ -251,6 +251,18 @@ describe Browser do
251
251
  assert_equal "11", @browser.version
252
252
  end
253
253
 
254
+ it "detects Lumia 800" do
255
+ @browser.ua = $ua["LUMIA800"]
256
+
257
+ assert_equal "Internet Explorer", @browser.name
258
+ assert @browser.ie?
259
+ assert @browser.ie9?
260
+ assert_equal "9.0", @browser.full_version
261
+ assert_equal "9", @browser.version
262
+ refute @browser.tablet?
263
+ assert @browser.mobile?
264
+ end
265
+
254
266
  it "detects opera" do
255
267
  @browser.ua = $ua["OPERA"]
256
268
 
@@ -287,6 +299,7 @@ describe Browser do
287
299
  it "detects modern firefox" do
288
300
  @browser.ua = $ua["FIREFOX_MODERN"]
289
301
 
302
+ assert_equal :firefox, @browser.id
290
303
  assert_equal "Firefox", @browser.name
291
304
  assert @browser.firefox?
292
305
  assert @browser.modern?
@@ -297,7 +310,8 @@ describe Browser do
297
310
  it "detects firefox android tablet" do
298
311
  @browser.ua = $ua["FIREFOX_TABLET"]
299
312
 
300
- assert_equal "Android", @browser.name
313
+ assert_equal :firefox, @browser.id
314
+ assert_equal "Firefox", @browser.name
301
315
  assert @browser.firefox?
302
316
  assert @browser.modern?
303
317
  assert @browser.tablet?
@@ -624,11 +638,33 @@ describe Browser do
624
638
  assert @browser.windows?
625
639
  end
626
640
 
641
+ it "detects windows_xp" do
642
+ @browser.ua = $ua["WINDOWS_XP"]
643
+
644
+ assert @browser.windows?
645
+ assert @browser.windows_xp?
646
+ end
647
+
648
+ it "detects windows_vista" do
649
+ @browser.ua = $ua["WINDOWS_VISTA"]
650
+
651
+ assert @browser.windows?
652
+ assert @browser.windows_vista?
653
+ end
654
+
655
+ it "detects windows7" do
656
+ @browser.ua = $ua["WINDOWS7"]
657
+
658
+ assert @browser.windows?
659
+ assert @browser.windows7?
660
+ end
661
+
627
662
  it "detects windows8" do
628
663
  @browser.ua = $ua["WINDOWS8"]
629
664
 
630
665
  assert @browser.windows?
631
666
  assert @browser.windows8?
667
+ refute @browser.windows8_1?
632
668
  end
633
669
 
634
670
  it "detects windows8.1" do
@@ -636,6 +672,7 @@ describe Browser do
636
672
 
637
673
  assert @browser.windows?
638
674
  assert @browser.windows8?
675
+ assert @browser.windows8_1?
639
676
  end
640
677
 
641
678
  it "detects linux platform" do
@@ -747,6 +784,15 @@ describe Browser do
747
784
  it "detects windows x64" do
748
785
  @browser.ua = $ua["IE10_X64_WINX64"]
749
786
  assert @browser.windows_x64?
787
+ refute @browser.windows_wow64?
788
+ assert @browser.windows_x64_inclusive?
789
+ end
790
+
791
+ it "detects windows wow64" do
792
+ @browser.ua = $ua["WINDOWS_WOW64"]
793
+ refute @browser.windows_x64?
794
+ assert @browser.windows_wow64?
795
+ assert @browser.windows_x64_inclusive?
750
796
  end
751
797
 
752
798
  it "detects ie11 touch desktop pc" do
@@ -764,6 +810,37 @@ describe Browser do
764
810
  assert_equal "11", @browser.version
765
811
  end
766
812
 
813
+ it "detects Microsoft Edge" do
814
+ @browser.ua = $ua["MS_EDGE"]
815
+
816
+ assert_equal :edge, @browser.id
817
+ assert_equal "Microsoft Edge", @browser.name
818
+ assert_equal "12.0", @browser.full_version
819
+ assert_equal "12", @browser.version
820
+ assert @browser.windows10?
821
+ assert @browser.edge?
822
+ refute @browser.webkit?
823
+ refute @browser.chrome?
824
+ refute @browser.safari?
825
+ refute @browser.mobile?
826
+ end
827
+
828
+ it "detects Microsoft Edge Mobile" do
829
+ @browser.ua = $ua["MS_EDGE_MOBILE"]
830
+
831
+ assert_equal :edge, @browser.id
832
+ assert_equal "Microsoft Edge", @browser.name
833
+ assert_equal "12.0", @browser.full_version
834
+ assert_equal "12", @browser.version
835
+ refute @browser.windows10?
836
+ assert @browser.windows_phone?
837
+ assert @browser.edge?
838
+ assert @browser.mobile?
839
+ refute @browser.webkit?
840
+ refute @browser.chrome?
841
+ refute @browser.safari?
842
+ end
843
+
767
844
  it "detects kindle monochrome" do
768
845
  @browser.ua = $ua["KINDLE"]
769
846
 
@@ -870,13 +947,16 @@ describe Browser do
870
947
 
871
948
  it "detects bots" do
872
949
  %w[
950
+ APPLE_BOT
873
951
  DOT_BOT
874
952
  FACEBOOK_BOT
875
953
  GOOGLE_BOT
876
954
  LINKDEXBOT
877
955
  LOAD_TIME_BOT
878
956
  MAIL_RU
957
+ MEGAINDEX_RU
879
958
  MSN_BOT
959
+ QUERYSEEKER
880
960
  SCRAPY
881
961
  YANDEX_DIRECT
882
962
  YANDEX_METRIKA
@@ -889,6 +969,11 @@ describe Browser do
889
969
  refute @browser.bot?
890
970
  end
891
971
 
972
+ it "detects Google Page Speed as a bot" do
973
+ @browser.ua = $ua["GOOGLE_PAGE_SPEED_INSIGHTS"]
974
+ assert @browser.bot?
975
+ end
976
+
892
977
  it "doesn't consider empty UA as bot" do
893
978
  @browser.ua = ""
894
979
  refute @browser.bot?
@@ -952,6 +1037,12 @@ describe Browser do
952
1037
  end
953
1038
  end
954
1039
 
1040
+ it "detects Google Structured Data Testing Tool as a bot" do
1041
+ @browser.ua = $ua["GOOGLE_STRUCTURED_DATA_TESTING_TOOL"]
1042
+
1043
+ assert @browser.bot?, "Google Structured Data Testing Tool should be a bot"
1044
+ end
1045
+
955
1046
  it "knows a supported browser" do
956
1047
  @browser.ua = "Chrome"
957
1048
  assert @browser.known?
@@ -1,7 +1,7 @@
1
1
  ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
2
2
  require "bundler/setup"
3
3
  require "minitest/autorun"
4
- require "minitest/unit"
4
+ require "minitest/utils"
5
5
  require "browser"
6
6
  require "yaml"
7
7
 
@@ -1,6 +1,7 @@
1
1
  ADOBE_AIR: 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; de) AppleWebKit/533.19.4 (KHTML, like Gecko) AdobeAIR/13.0'
2
2
  ANDROID: 'Android SDK 1.5r3: Mozilla/5.0 (Linux; U; Android 1.5; de-; sdk Build/CUPCAKE) AppleWebkit/528.5+ (KHTML, like Gecko) Version/3.1.2 Mobile Safari/525.20.1'
3
3
  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'
4
+ APPLE_BOT: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/600.2.5 (KHTML, like Gecko) Version/8.0.2 Safari/600.2.5 (Applebot/0.1)'
4
5
  ASK: 'Mozilla/2.0 (compatible; Ask Jeeves/Teoma; +http://sp.ask.com/docs/about/tech_crawling.html)'
5
6
  BAIDU: 'Baiduspider+(+http://www.baidu.com/search/spider.htm)'
6
7
  BINGBOT: 'Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)'
@@ -20,6 +21,8 @@ FIREFOX: 'Mozilla/5.0 (X11; U; Linux i686; pl-PL; rv:1.9.0.2) Gecko/20121223 Ubu
20
21
  FIREFOX_MODERN: 'Mozilla/5.0 (X11; Ubuntu; Linux armv7l; rv:17.0) Gecko/20100101 Firefox/17.0'
21
22
  FIREFOX_TABLET: 'Mozilla/5.0 (Android; Tablet; rv:14.0) Gecko/14.0 Firefox/14.0'
22
23
  GOOGLE_BOT: 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'
24
+ GOOGLE_PAGE_SPEED_INSIGHTS: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.4 (KHTML, like Gecko; Google Page Speed Insights) Chrome/22.0.1229 Safari/537.4'
25
+ GOOGLE_STRUCTURED_DATA_TESTING_TOOL: 'Mozilla/5.0 (compatible; X11; Linux x86_64; Google-StructuredDataTestingTool; +http://www.google.com/webmasters/tools/richsnippets)'
23
26
  IE10: 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0; EIE10;ENUSMSN)'
24
27
  IE10_COMPAT: 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/6.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; EIE10;ENUSMSN)'
25
28
  IE10_X64_WINX64: 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Win64; x64; Trident/6.0)'
@@ -31,6 +34,8 @@ IE8: 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.2; Trident/4.0; SLCC2; .NE
31
34
  IE8_COMPAT: 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/4.0; SLCC1; Media Center PC 5.0; .NET CLR 3.5.21022)'
32
35
  IE9: 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)'
33
36
  IE9_COMPAT: 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/5.0)'
37
+ MS_EDGE: 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 Edge/12.0'
38
+ MS_EDGE_MOBILE: 'Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; DEVICE INFO) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Mobile Safari/537.36 Edge/12.0'
34
39
  IOS4: 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7'
35
40
  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'
36
41
  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'
@@ -45,7 +50,9 @@ KINDLE_FIRE_HD: 'Mozilla/5.0 (Linux; U; en-us; KFTT Build/IML74K) AppleWebKit/53
45
50
  KINDLE_FIRE_HD_MOBILE: 'Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; KFTT Build/IML74K) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.4 Mobile Safari/535.19 Silk-Accelerated=true'
46
51
  LINKDEXBOT: 'Mozilla/5.0 (compatible; linkdexbot/2.0; +http://www.linkdex.com/bots/)'
47
52
  LOAD_TIME_BOT: 'Mozilla/5.0 (compatible; LoadTimeBot/0.9; +http://www.loadtime.net/bot.html)'
53
+ LUMIA800: 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; XBLWP7; ZuneWP7'
48
54
  MAIL_RU: 'Mozilla/5.0 (compatible; Linux x86_64; Mail.RU_Bot/2.0; +http://go.mail.ru/help/robots)'
55
+ MEGAINDEX_RU: 'Mozilla/5.0 (compatible; MegaIndex.ru/2.0; +https://www.megaindex.ru/?tab=linkAnalyze)'
49
56
  MOBILE_CHROME: 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_1_1 like Mac OS X; en) AppleWebKit/534.46.0 (KHTML, like Gecko) CriOS/19.0.1084.60 Mobile/9B206 Safari/7534.48.3'
50
57
  MSN_BOT: 'msnbot-media/1.1 (+http://search.msn.com/msnbot.htm)'
51
58
  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'
@@ -63,6 +70,7 @@ PLAYSTATION4: 'Mozilla/5.0 (PlayStation 4 1.020) AppleWebKit/536.26 (KHTML, like
63
70
  PSP: 'Mozilla/4.0 (PSP (PlayStation Portable); 2.00)'
64
71
  PSP_VITA: 'Mozilla/5.0 (Playstation Vita 1.61) AppleWebKit/531.22.8 (KHTML, like Gecko) Silk/3.2'
65
72
  QUICKTIME: 'QuickTime/7.6.8 (qtver=7.6.8;os=Windows NT 5.1Service Pack 3)'
73
+ QUERYSEEKER: 'QuerySeekerSpider ( http://queryseeker.com/bot.html )'
66
74
  SAFARI: 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-us) AppleWebKit/533.17.8 (KHTML, like Gecko) Version/5.0.1 Safari/533.17.8'
67
75
  SAFARI_IPAD_WEBAPP_MODE: 'Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405'
68
76
  SAFARI_IPHONE_WEBAPP_MODE: 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.20 (KHTML, like Gecko) Mobile/7B298g'
@@ -72,8 +80,12 @@ SCRAPY: 'Scrapy/0.18.4 (+http://scrapy.org)'
72
80
  SMART_TV: 'Mozilla/5.0 (SmartHub; SMART-TV; U; Linux/SmartTV) AppleWebKit/531.2+ (KHTML, like Gecko) WebBrowser/1.0 SmartTV Safari/531.2+'
73
81
  SURFACE: 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; ARM; Trident/6.0; Touch)'
74
82
  TABLOID: 'Mozilla/5.0 (Linux; U; Android 3.0; en-us; Xoom Build/HRI39) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13'
83
+ WINDOWS_XP: 'Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; FDM; .NET CLR 1.1.4322)'
84
+ WINDOWS_VISTA: 'Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 1.0.3705; .NET CLR 1.1.4322)'
85
+ WINDOWS7: 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0) chromeframe/10.0.648.205'
75
86
  WINDOWS81: 'Mozilla/5.0 (IE 11.0; Windows NT 6.3; Trident/7.0; .NET4.0E; .NET4.0C; rv:11.0) like Gecko'
76
87
  WINDOWS8: 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)'
88
+ WINDOWS_WOW64: "Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; Touch; rv:11.0) like Gecko"
77
89
  WINDOWS_MOBILE: 'Mozilla/4.0 (compatible; MSIE 6.0; Windows CE; IEMobile 6.12)'
78
90
  WINDOWS_PHONE8: 'Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920)'
79
91
  WINDOWS_PHONE: 'Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; DELL; Venue Pro)'
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.8.0
4
+ version: 0.9.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-11-20 00:00:00.000000000 Z
11
+ date: 2015-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: minitest-utils
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  description: Do some browser detection with Ruby.
84
98
  email:
85
99
  - fnando.vieira@gmail.com
@@ -89,6 +103,7 @@ extra_rdoc_files: []
89
103
  files:
90
104
  - ".gitignore"
91
105
  - ".hound.yml"
106
+ - ".rubocop.yml"
92
107
  - ".travis.yml"
93
108
  - CONTRIBUTING.md
94
109
  - Gemfile
@@ -132,7 +147,8 @@ files:
132
147
  - test/spec_helper.rb
133
148
  - test/ua.yml
134
149
  homepage: http://github.com/fnando/browser
135
- licenses: []
150
+ licenses:
151
+ - MIT
136
152
  metadata: {}
137
153
  post_install_message:
138
154
  rdoc_options: []
@@ -150,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
166
  version: '0'
151
167
  requirements: []
152
168
  rubyforge_project:
153
- rubygems_version: 2.2.2
169
+ rubygems_version: 2.4.6
154
170
  signing_key:
155
171
  specification_version: 4
156
172
  summary: Do some browser detection with Ruby.