browser 2.0.3 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +9 -6
- data/CHANGELOG.md +12 -0
- data/README.md +8 -2
- data/bots.yml +7 -2
- data/browser.gemspec +1 -0
- data/lib/browser.rb +4 -7
- data/lib/browser/accept_language.rb +9 -1
- data/lib/browser/base.rb +11 -0
- data/lib/browser/micro_messenger.rb +20 -0
- data/lib/browser/platform/adobe_air.rb +1 -1
- data/lib/browser/platform/mac.rb +1 -1
- data/lib/browser/platform/windows.rb +1 -1
- data/lib/browser/version.rb +1 -1
- data/lib/browser/weibo.rb +20 -0
- data/test/browser_test.rb +1 -0
- data/test/test_helper.rb +3 -0
- data/test/ua.yml +6 -0
- data/test/ua_bots.yml +5 -0
- data/test/unit/accept_language_test.rb +9 -0
- data/test/unit/adobe_air_test.rb +2 -0
- data/test/unit/device_test.rb +9 -0
- data/test/unit/generic_test.rb +22 -0
- data/test/unit/micro_messenger_test.rb +14 -0
- data/test/unit/platform_test.rb +1 -1
- data/test/unit/safari_test.rb +18 -0
- data/test/unit/weibo_test.rb +18 -0
- data/test/unit/windows_test.rb +35 -0
- metadata +24 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec8732c321a4cf1e50c785d07a242a87e03d599e
|
4
|
+
data.tar.gz: 7c2632f4db32249d9b3411b7d8c99c24d3ae2ade
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa5e391f8d1ad5deed626581151df145f55ad6f2509592bb591ccf41f3446c0f4a249aa4e38dcfad53612c8a0caec7aafb94f685b1413bc3697bca8c9fd9777e
|
7
|
+
data.tar.gz: ce44b976d82b7d8ac431fc5333eaf43b5a7141658308b7c549cf56d13ccd64a20fb35738dd84078f1a83cf277ec6e14621971cc5fa2fc1fc25157768353122bb
|
data/.travis.yml
CHANGED
@@ -2,12 +2,15 @@ language: ruby
|
|
2
2
|
sudo: false
|
3
3
|
cache: bundler
|
4
4
|
rvm:
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
- '2.3.1'
|
6
|
+
- '2.2'
|
7
|
+
- '2.1'
|
8
8
|
gemfile:
|
9
|
-
|
10
|
-
|
11
|
-
script:
|
9
|
+
- Gemfile
|
10
|
+
- gemfiles/rails3.gemfile
|
11
|
+
script: bundle exec rake
|
12
12
|
notifications:
|
13
13
|
email: false
|
14
|
+
env:
|
15
|
+
global:
|
16
|
+
secure: egPPk/jMVzOoZGkk8jcf1f1N++oI4p4hqtk53T2kpHChxpmR8sP/oFlAhebvqMhM8svbQx+lWTvdxPDj9GBQGsC4ekqubV6S0MNJQS4/F41PSEU+DFUzNU1PHiDO+/0AbIheTj15UIt8IC4NVaM236HuSdMDWOjVI3ydBsgJ/GY=
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v2.1.0
|
4
|
+
|
5
|
+
- Add PrivacyAwareBot, ltx71, Squider and Traackr to bots.
|
6
|
+
- Match Google Structured Data alternative bot.
|
7
|
+
- Match MicroMessenger (WeChat).
|
8
|
+
- Match Weibo.
|
9
|
+
- Detect Windows & Mac OS versions.
|
10
|
+
|
11
|
+
## v2.0.3
|
12
|
+
|
13
|
+
- Fix issue with version detection when no actual version is provided (i.e. the user agent doesn't have any version information).
|
14
|
+
|
3
15
|
## v2.0.2
|
4
16
|
|
5
17
|
- Fix issue when user agent is set to `nil`.
|
data/README.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# Browser
|
2
2
|
|
3
3
|
[![Travis-CI](https://travis-ci.org/fnando/browser.png)](https://travis-ci.org/fnando/browser)
|
4
|
-
[![
|
4
|
+
[![Code Climate](https://codeclimate.com/github/fnando/browser/badges/gpa.svg)](https://codeclimate.com/github/fnando/browser)
|
5
|
+
[![Test Coverage](https://codeclimate.com/github/fnando/browser/badges/coverage.svg)](https://codeclimate.com/github/fnando/browser/coverage)
|
5
6
|
[![Gem](https://img.shields.io/gem/v/browser.svg)](https://rubygems.org/gems/browser)
|
6
7
|
[![Gem](https://img.shields.io/gem/dt/browser.svg)](https://rubygems.org/gems/browser)
|
7
8
|
|
@@ -47,6 +48,8 @@ browser.version # major version number
|
|
47
48
|
browser.webkit?
|
48
49
|
browser.webkit_full_version
|
49
50
|
browser.yandex?
|
51
|
+
browser.wechat? # detect the MicroMessenger(WeChat)
|
52
|
+
browser.weibo? # detect Weibo embedded browser (Sina Weibo)
|
50
53
|
|
51
54
|
# Get bot info
|
52
55
|
browser.bot.name
|
@@ -181,7 +184,10 @@ language.name
|
|
181
184
|
#=> "English/United States"
|
182
185
|
```
|
183
186
|
|
184
|
-
Result is always sorted in quality order from highest -> lowest.
|
187
|
+
Result is always sorted in quality order from highest -> lowest. As per the HTTP spec:
|
188
|
+
|
189
|
+
- omitting the quality value implies 1.0.
|
190
|
+
- quality value equal to zero means that is not accepted by the client.
|
185
191
|
|
186
192
|
### Internet Explorer
|
187
193
|
|
data/bots.yml
CHANGED
@@ -68,6 +68,8 @@ gimmeusabot: "Gimme60 (gimme60.com)"
|
|
68
68
|
go http package: "Go http library"
|
69
69
|
google page speed insights: "Google Page Speed Insights"
|
70
70
|
google Web Preview: "Google Instant Previews crawler"
|
71
|
+
google-structured-data-testing-tool: "Google-StructuredDataTestingTool"
|
72
|
+
google-structureddatatestingtool: "Google-StructuredDataTestingTool"
|
71
73
|
googlebot: "Google Bot"
|
72
74
|
grapeshotcrawler: "GrapeshotCrawler"
|
73
75
|
gravitybot: "Gravity Bot"
|
@@ -108,6 +110,7 @@ lipperhey: "Lipperhey"
|
|
108
110
|
livelapbot: "Livelapbot"
|
109
111
|
loadtimebot: "Load Time Bot"
|
110
112
|
longurl: "URL expander service"
|
113
|
+
ltx71: "ltx71.com"
|
111
114
|
lumibot: "Lumibot"
|
112
115
|
lwp-trivial: "Another Perl library"
|
113
116
|
magpie-crawler: "magpie-crawler"
|
@@ -121,6 +124,7 @@ mfe_expand: "Mcafee spider"
|
|
121
124
|
mir web crawler: "MIR web crawler"
|
122
125
|
mj12bot: "Majestic-12 spider"
|
123
126
|
mojeekbot: "Mojeek UK search crawler"
|
127
|
+
mrchrome: "MrChrome"
|
124
128
|
ms search 6.0 robot: "MS Search 6.0 Robot"
|
125
129
|
msnbot: "Microsoft bot"
|
126
130
|
nerdybot: "NerdyBot"
|
@@ -144,6 +148,7 @@ phantomjs: "PhantomJS"
|
|
144
148
|
pingdom: "Pingdom monitoring"
|
145
149
|
pinterest: "Pinterest"
|
146
150
|
plukkie: "botje.com/plukkie.htm"
|
151
|
+
privacyawarebot: "PrivacyAwareBot"
|
147
152
|
psbot-page: "Picsearch"
|
148
153
|
publiclibraryarchive.org: "publiclibraryarchive.org"
|
149
154
|
pycurl: "Python http library"
|
@@ -182,10 +187,11 @@ spbot: "OpenLinkProfiler"
|
|
182
187
|
spider: "generic web spider"
|
183
188
|
spinn3r: "Spinn3r aggregator"
|
184
189
|
sputnikbot: "SputnikBot"
|
190
|
+
squider: "Squider"
|
185
191
|
statuscake: "StatusCake"
|
186
|
-
structureddatatestingtool: 'Google-StructuredDataTestingTool'
|
187
192
|
test certificate info: "C http library?"
|
188
193
|
tineye: "TinEye Bot"
|
194
|
+
traackr: "Traackr Bot"
|
189
195
|
trendictionbot: "Trendiction Search"
|
190
196
|
turnitinbot: "TurnitinBot"
|
191
197
|
tweetedtimes: "The Tweeted Times"
|
@@ -223,4 +229,3 @@ zelist.ro: "feed parser"
|
|
223
229
|
zibb: "ZIBB spider"
|
224
230
|
zitebot: "Zite"
|
225
231
|
zyborg: "Zyborg"
|
226
|
-
mrchrome: "MrChrome"
|
data/browser.gemspec
CHANGED
data/lib/browser.rb
CHANGED
@@ -17,6 +17,8 @@ require "browser/generic"
|
|
17
17
|
require "browser/phantom_js"
|
18
18
|
require "browser/uc_browser"
|
19
19
|
require "browser/nokia"
|
20
|
+
require "browser/micro_messenger"
|
21
|
+
require "browser/weibo"
|
20
22
|
|
21
23
|
require "browser/bot"
|
22
24
|
require "browser/middleware"
|
@@ -91,8 +93,10 @@ module Browser
|
|
91
93
|
Edge,
|
92
94
|
InternetExplorer,
|
93
95
|
Firefox,
|
96
|
+
Weibo, # must be placed before Chrome and Safari
|
94
97
|
Chrome,
|
95
98
|
Safari,
|
99
|
+
MicroMessenger,
|
96
100
|
Generic
|
97
101
|
]
|
98
102
|
end
|
@@ -125,11 +129,4 @@ module Browser
|
|
125
129
|
.map {|klass| klass.new(user_agent || EMPTY_STRING, **kwargs) }
|
126
130
|
.find(&:match?)
|
127
131
|
end
|
128
|
-
|
129
|
-
private
|
130
|
-
|
131
|
-
def deprecate(message)
|
132
|
-
offender = caller[1].to_s[/^(.*?\.rb:\d+).*?$/, 1]
|
133
|
-
$stderr << "\n#{message} (called from #{offender})\n"
|
134
|
-
end
|
135
132
|
end
|
@@ -12,6 +12,7 @@ module Browser
|
|
12
12
|
.split(",")
|
13
13
|
.map {|string| string.squeeze(" ").strip }
|
14
14
|
.map {|part| new(part) }
|
15
|
+
.reject {|al| al.quality.zero? }
|
15
16
|
.sort_by(&:quality)
|
16
17
|
.reverse
|
17
18
|
end
|
@@ -42,7 +43,14 @@ module Browser
|
|
42
43
|
end
|
43
44
|
|
44
45
|
def quality
|
45
|
-
@quality ||= Float(
|
46
|
+
@quality ||= Float(quality_value || 1.0)
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def quality_value
|
52
|
+
qvalue = part[/;q=([\d.]+)/, 1]
|
53
|
+
qvalue =~ /\A0\.0?\z/ ? "0.0" : qvalue
|
46
54
|
end
|
47
55
|
end
|
48
56
|
end
|
data/lib/browser/base.rb
CHANGED
@@ -136,6 +136,17 @@ module Browser
|
|
136
136
|
Nokia.new(ua).match?
|
137
137
|
end
|
138
138
|
|
139
|
+
# Detect if browser is MicroMessenger.
|
140
|
+
def micro_messenger?
|
141
|
+
MicroMessenger.new(ua).match?
|
142
|
+
end
|
143
|
+
|
144
|
+
alias_method :wechat?, :micro_messenger?
|
145
|
+
|
146
|
+
def weibo?
|
147
|
+
Weibo.new(ua).match?
|
148
|
+
end
|
149
|
+
|
139
150
|
# Detect if browser is Opera Mini.
|
140
151
|
def opera_mini?
|
141
152
|
ua =~ /Opera Mini/
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Browser
|
3
|
+
class MicroMessenger < Base
|
4
|
+
def id
|
5
|
+
:micro_messenger
|
6
|
+
end
|
7
|
+
|
8
|
+
def name
|
9
|
+
"MicroMessenger"
|
10
|
+
end
|
11
|
+
|
12
|
+
def full_version
|
13
|
+
ua[%r[(?:MicroMessenger)/([\d.]+)]i, 1] || "0.0"
|
14
|
+
end
|
15
|
+
|
16
|
+
def match?
|
17
|
+
ua =~ /MicroMessenger/i
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/browser/platform/mac.rb
CHANGED
data/lib/browser/version.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Browser
|
3
|
+
class Weibo < Base
|
4
|
+
def id
|
5
|
+
:weibo
|
6
|
+
end
|
7
|
+
|
8
|
+
def name
|
9
|
+
"Weibo"
|
10
|
+
end
|
11
|
+
|
12
|
+
def full_version
|
13
|
+
ua[%r[(?:__weibo__)([\d.]+)]i, 1] || "0.0"
|
14
|
+
end
|
15
|
+
|
16
|
+
def match?
|
17
|
+
ua =~ /__weibo__/i
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/test/browser_test.rb
CHANGED
@@ -88,6 +88,7 @@ class BrowserTest < Minitest::Test
|
|
88
88
|
browser = Browser.new(Browser["PHANTOM_JS"])
|
89
89
|
|
90
90
|
assert_equal "PhantomJS", browser.name
|
91
|
+
assert_equal :phantom_js, browser.id
|
91
92
|
assert browser.phantom_js?
|
92
93
|
assert browser.modern?
|
93
94
|
assert_equal "1.9.0", browser.full_version
|
data/test/test_helper.rb
CHANGED
data/test/ua.yml
CHANGED
@@ -101,9 +101,12 @@ SURFACE: 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; ARM; Trident/6.0;
|
|
101
101
|
SYMBIAN: 'Nokia5250/10.0.011 (SymbianOS/9.4; U; Series60/5.0 Mozilla/5.0; Profile/MIDP-2.1 Configuration/CLDC-1.1 ) AppleWebKit/525 (KHTML, like Gecko) Safari/525 3gpp-gba'
|
102
102
|
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'
|
103
103
|
UC_BROWSER: 'Mozilla/5.0 (Linux; U; Android 4.4.2; en-US; GT-I9500 Build/KOT49H) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 UCBrowser/9.9.4.484 U3/0.8.0 Mobile Safari/533.1'
|
104
|
+
WINDOWS_2000: 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 5.0; Trident/6.0)'
|
105
|
+
WINDOWS_2000_SP1: 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 5.01; Trident/6.0)'
|
104
106
|
WINDOWS7: 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0) chromeframe/10.0.648.205'
|
105
107
|
WINDOWS81: 'Mozilla/5.0 (IE 11.0; Windows NT 6.3; Trident/7.0; .NET4.0E; .NET4.0C; rv:11.0) like Gecko'
|
106
108
|
WINDOWS8: 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)'
|
109
|
+
WINDOWS10: 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 10.0; Trident/6.0)'
|
107
110
|
WINDOWS_MOBILE: 'Mozilla/4.0 (compatible; MSIE 6.0; Windows CE; IEMobile 6.12)'
|
108
111
|
WINDOWS_PHONE8: 'Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920)'
|
109
112
|
WINDOWS_PHONE: 'Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; DELL; Venue Pro)'
|
@@ -116,3 +119,6 @@ XBOX360: 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; Xbox),
|
|
116
119
|
XBOXONE: 'Mozilla/5.0 (Compatible; MSIE 10.0; Windows NT 6.2; Trident /6.0; Xbox; Xbox One)'
|
117
120
|
XOOM: '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'
|
118
121
|
YANDEX_BROWSER: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 YaBrowser/15.4.2272.3909 (beta) Yowser/2.0 Safari/537.36'
|
122
|
+
MICRO_MESSENGER: 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_3_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Mobile/13E238 MicroMessenger/6.3.15 NetType/3G+ Language/zh_CN'
|
123
|
+
WEIBO_IOS: 'Mozilla/5.0 (iPhone; CPU iPhone OS 8_4 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12H143 Weibo (iPhone7,2__weibo__5.7.1__iphone__os8.4)'
|
124
|
+
WEIBO_ANDROID: 'Mozilla/5.0 (Linux; Android 5.0.2; vivo X5M Build/LRX22G) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/37.0.0.0 Mobile Safari/537.36 Weibo (vivo-vivo X5M__weibo__5.7.1__android__android5.0.2)'
|
data/test/ua_bots.yml
CHANGED
@@ -10,18 +10,23 @@ FACEBOOK_BOT: 'facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uat
|
|
10
10
|
GOOGLE_BOT: 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'
|
11
11
|
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'
|
12
12
|
GOOGLE_STRUCTURED_DATA_TESTING_TOOL: 'Mozilla/5.0 (compatible; X11; Linux x86_64; Google-StructuredDataTestingTool; +http://www.google.com/webmasters/tools/richsnippets)'
|
13
|
+
GOOGLE_STRUCTURED_DATA_TESTING_TOOL2: 'Mozilla/5.0 (compatible; Google-Structured-Data-Testing-Tool +http://developers.google.com/structured-data/testing-tool/)'
|
13
14
|
GRAPESHOT: 'Mozilla/5.0 (compatible; GrapeshotCrawler/2.0; +http://www.grapeshot.co.uk/crawler.php)'
|
14
15
|
LINKDEXBOT: 'Mozilla/5.0 (compatible; linkdexbot/2.0; +http://www.linkdex.com/bots/)'
|
15
16
|
LOAD_TIME_BOT: 'Mozilla/5.0 (compatible; LoadTimeBot/0.9; +http://www.loadtime.net/bot.html)'
|
17
|
+
LTX71: 'ltx71 - (http://ltx71.com/)'
|
16
18
|
MAIL_RU: 'Mozilla/5.0 (compatible; Linux x86_64; Mail.RU_Bot/2.0; +http://go.mail.ru/help/robots)'
|
17
19
|
MEGAINDEX_RU: 'Mozilla/5.0 (compatible; MegaIndex.ru/2.0; +https://www.megaindex.ru/?tab=linkAnalyze)'
|
18
20
|
MRCHROME: 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.107 Amigo/45.0.2454.107 MRCHROME SOC Safari/537.36'
|
19
21
|
MSN_BOT: 'msnbot-media/1.1 (+http://search.msn.com/msnbot.htm)'
|
22
|
+
PRIVACYAWAREBOT: 'Mozilla/5.0 (compatible; PrivacyAwareBot/1.1; +http://www.privacyaware.org)'
|
20
23
|
QUERYSEEKER: 'QuerySeekerSpider ( http://queryseeker.com/bot.html )'
|
21
24
|
SCRAPY: 'Scrapy/0.18.4 (+http://scrapy.org)'
|
22
25
|
SEOKICKS: 'Mozilla/5.0 (compatible; SEOkicks-Robot; +http://www.seokicks.de/robot.html)'
|
23
26
|
SISTRIX: 'Mozilla/5.0 (compatible; SISTRIX Crawler; http://crawler.sistrix.net/)'
|
27
|
+
SQUIDER: 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36 Squider/0.01'
|
24
28
|
TINEYE: 'TinEye-bot/0.51 (see http://www.tineye.com/crawler.html)'
|
29
|
+
TRAACKR: 'Traackr.com'
|
25
30
|
YAHOO_SLURP: 'Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)'
|
26
31
|
YANDEX_DIRECT: 'Mozilla/5.0 (compatible; YandexDirect/3.0; +http://yandex.com/bots)'
|
27
32
|
YANDEX_METRIKA: 'Mozilla/5.0 (compatible; YandexMetrika/3.0; +http://yandex.com/bots)'
|
@@ -90,4 +90,13 @@ class AcceptLanguageTest < Minitest::Test
|
|
90
90
|
assert_language result[3], code: "en", region: nil, quality: 0.4
|
91
91
|
assert_language result[4], code: "fr", region: nil, quality: 0.2
|
92
92
|
end
|
93
|
+
|
94
|
+
test "rejects quality values equals to zero (#241)" do
|
95
|
+
result = Browser::AcceptLanguage.parse("de-DE,ru;q=0.9,de;q=0.8,en;q=0.")
|
96
|
+
|
97
|
+
assert_equal 3, result.size
|
98
|
+
assert_language result[0], code: "de", region: "DE", quality: 1.0
|
99
|
+
assert_language result[1], code: "ru", region: nil, quality: 0.9
|
100
|
+
assert_language result[2], code: "de", region: nil, quality: 0.8
|
101
|
+
end
|
93
102
|
end
|
data/test/unit/adobe_air_test.rb
CHANGED
@@ -9,5 +9,7 @@ class AdobeAirTest < Minitest::Test
|
|
9
9
|
assert_equal "0", browser.version
|
10
10
|
assert_equal "0.0", browser.full_version
|
11
11
|
assert_equal "Generic Browser", browser.name
|
12
|
+
assert_equal "Adobe AIR", browser.platform.name
|
13
|
+
assert_equal "13.0", browser.platform.version
|
12
14
|
end
|
13
15
|
end
|
data/test/unit/device_test.rb
CHANGED
@@ -74,6 +74,7 @@ class DeviceTest < Minitest::Test
|
|
74
74
|
|
75
75
|
assert device.console?
|
76
76
|
assert device.xbox?
|
77
|
+
assert device.xbox_360?
|
77
78
|
refute device.xbox_one?
|
78
79
|
assert_equal :xbox_360, device.id
|
79
80
|
assert_equal "Xbox 360", device.name
|
@@ -85,6 +86,7 @@ class DeviceTest < Minitest::Test
|
|
85
86
|
assert device.console?
|
86
87
|
assert device.xbox?
|
87
88
|
assert device.xbox_one?
|
89
|
+
refute device.xbox_360?
|
88
90
|
assert_equal :xbox_one, device.id
|
89
91
|
assert_equal "Xbox One", device.name
|
90
92
|
end
|
@@ -169,6 +171,13 @@ class DeviceTest < Minitest::Test
|
|
169
171
|
assert_equal "TV", device.name
|
170
172
|
end
|
171
173
|
|
174
|
+
test "detect unknown device" do
|
175
|
+
device = Browser::Device.new("")
|
176
|
+
|
177
|
+
assert device.unknown?
|
178
|
+
assert_equal "Unknown", device.name
|
179
|
+
end
|
180
|
+
|
172
181
|
%w[
|
173
182
|
ANDROID
|
174
183
|
SYMBIAN
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class GenericTest < Minitest::Test
|
4
|
+
test "return default msie version" do
|
5
|
+
browser = Browser.new("")
|
6
|
+
|
7
|
+
assert_equal "0.0", browser.msie_full_version
|
8
|
+
assert_equal "0", browser.msie_version
|
9
|
+
end
|
10
|
+
|
11
|
+
test "return default compatibility view" do
|
12
|
+
browser = Browser.new("")
|
13
|
+
|
14
|
+
refute browser.compatibility_view?
|
15
|
+
end
|
16
|
+
|
17
|
+
test "return default safari web app mode" do
|
18
|
+
browser = Browser.new("")
|
19
|
+
|
20
|
+
refute browser.safari_webapp_mode?
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "test_helper"
|
3
|
+
|
4
|
+
class MicroMessengerTest < Minitest::Test
|
5
|
+
test "detects micro messenger 6.3.15" do
|
6
|
+
browser = Browser.new(Browser["MICRO_MESSENGER"])
|
7
|
+
|
8
|
+
assert browser.micro_messenger?
|
9
|
+
assert browser.wechat?
|
10
|
+
assert_equal "6.3.15", browser.full_version
|
11
|
+
assert_equal "MicroMessenger", browser.name
|
12
|
+
assert_equal :micro_messenger, browser.id
|
13
|
+
end
|
14
|
+
end
|
data/test/unit/platform_test.rb
CHANGED
data/test/unit/safari_test.rb
CHANGED
@@ -64,4 +64,22 @@ class SafariTest < Minitest::Test
|
|
64
64
|
assert_equal "9", browser.version
|
65
65
|
assert_equal "9.0.2", browser.full_version
|
66
66
|
end
|
67
|
+
|
68
|
+
test "detect web app mode" do
|
69
|
+
browser = Browser.new(Browser["SAFARI_IPHONE_WEBAPP_MODE"])
|
70
|
+
|
71
|
+
assert browser.safari_webapp_mode?
|
72
|
+
end
|
73
|
+
|
74
|
+
test "reject regular safari as web app mode" do
|
75
|
+
browser = Browser.new(Browser["SAFARI9"])
|
76
|
+
|
77
|
+
refute browser.safari_webapp_mode?
|
78
|
+
end
|
79
|
+
|
80
|
+
test "returns webkit version" do
|
81
|
+
browser = Browser.new(Browser["SAFARI9"])
|
82
|
+
|
83
|
+
assert_equal "601.3.9", browser.webkit_full_version
|
84
|
+
end
|
67
85
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "test_helper"
|
3
|
+
|
4
|
+
class MicroMessengerTest < Minitest::Test
|
5
|
+
test "detects weibo iOS" do
|
6
|
+
browser = Browser.new(Browser["WEIBO_IOS"])
|
7
|
+
assert browser.weibo?
|
8
|
+
assert_equal "Weibo", browser.name
|
9
|
+
assert_equal "5.7.1", browser.full_version
|
10
|
+
end
|
11
|
+
|
12
|
+
test "detects weibo Android" do
|
13
|
+
browser = Browser.new(Browser["WEIBO_ANDROID"])
|
14
|
+
assert browser.weibo?
|
15
|
+
assert_equal "Weibo", browser.name
|
16
|
+
assert_equal "5.7.1", browser.full_version
|
17
|
+
end
|
18
|
+
end
|
data/test/unit/windows_test.rb
CHANGED
@@ -7,6 +7,7 @@ class WindowsTest < Minitest::Test
|
|
7
7
|
assert browser.platform.windows_x64?
|
8
8
|
refute browser.platform.windows_wow64?
|
9
9
|
assert browser.platform.windows_x64_inclusive?
|
10
|
+
assert_equal browser.platform.version, "6.2"
|
10
11
|
end
|
11
12
|
|
12
13
|
test "detects windows wow64" do
|
@@ -14,6 +15,21 @@ class WindowsTest < Minitest::Test
|
|
14
15
|
refute browser.platform.windows_x64?
|
15
16
|
assert browser.platform.windows_wow64?
|
16
17
|
assert browser.platform.windows_x64_inclusive?
|
18
|
+
assert_equal browser.platform.version, "6.3"
|
19
|
+
end
|
20
|
+
|
21
|
+
test "detects windows_2000" do
|
22
|
+
browser = Browser.new(Browser["WINDOWS_2000"])
|
23
|
+
|
24
|
+
assert browser.platform.windows?
|
25
|
+
assert_equal browser.platform.version, "5.0"
|
26
|
+
end
|
27
|
+
|
28
|
+
test "detects windows_2000_sp1" do
|
29
|
+
browser = Browser.new(Browser["WINDOWS_2000_SP1"])
|
30
|
+
|
31
|
+
assert browser.platform.windows?
|
32
|
+
assert_equal browser.platform.version, "5.01"
|
17
33
|
end
|
18
34
|
|
19
35
|
test "detects windows_xp" do
|
@@ -21,6 +37,7 @@ class WindowsTest < Minitest::Test
|
|
21
37
|
|
22
38
|
assert browser.platform.windows?
|
23
39
|
assert browser.platform.windows_xp?
|
40
|
+
assert_equal browser.platform.version, "5.1"
|
24
41
|
end
|
25
42
|
|
26
43
|
test "detects windows_xp (64-bit)" do
|
@@ -29,6 +46,7 @@ class WindowsTest < Minitest::Test
|
|
29
46
|
assert browser.platform.windows?
|
30
47
|
assert browser.platform.windows_xp?
|
31
48
|
assert browser.platform.windows_x64?
|
49
|
+
assert_equal browser.platform.version, "5.2"
|
32
50
|
end
|
33
51
|
|
34
52
|
test "detects windows_vista" do
|
@@ -36,6 +54,7 @@ class WindowsTest < Minitest::Test
|
|
36
54
|
|
37
55
|
assert browser.platform.windows?
|
38
56
|
assert browser.platform.windows_vista?
|
57
|
+
assert_equal browser.platform.version, "6.0"
|
39
58
|
end
|
40
59
|
|
41
60
|
test "detects windows7" do
|
@@ -43,6 +62,7 @@ class WindowsTest < Minitest::Test
|
|
43
62
|
|
44
63
|
assert browser.platform.windows?
|
45
64
|
assert browser.platform.windows7?
|
65
|
+
assert_equal browser.platform.version, "6.1"
|
46
66
|
end
|
47
67
|
|
48
68
|
test "detects windows8" do
|
@@ -51,6 +71,7 @@ class WindowsTest < Minitest::Test
|
|
51
71
|
assert browser.platform.windows?
|
52
72
|
assert browser.platform.windows8?
|
53
73
|
refute browser.platform.windows8_1?
|
74
|
+
assert_equal browser.platform.version, "6.2"
|
54
75
|
end
|
55
76
|
|
56
77
|
test "detects windows8.1" do
|
@@ -59,5 +80,19 @@ class WindowsTest < Minitest::Test
|
|
59
80
|
assert browser.platform.windows?
|
60
81
|
assert browser.platform.windows8?
|
61
82
|
assert browser.platform.windows8_1?
|
83
|
+
assert_equal browser.platform.version, "6.3"
|
84
|
+
end
|
85
|
+
|
86
|
+
test "detects windows10" do
|
87
|
+
browser = Browser.new(Browser["WINDOWS10"])
|
88
|
+
|
89
|
+
assert browser.platform.windows?
|
90
|
+
assert browser.platform.windows10?
|
91
|
+
assert_equal browser.platform.version, "10.0"
|
92
|
+
end
|
93
|
+
|
94
|
+
test "returns name" do
|
95
|
+
browser = Browser.new(Browser["WINDOWS8"])
|
96
|
+
assert_equal "Windows", browser.platform.name
|
62
97
|
end
|
63
98
|
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: 2.0
|
4
|
+
version: 2.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: 2016-
|
11
|
+
date: 2016-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: codeclimate-test-reporter
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
125
139
|
description: Do some browser detection with Ruby.
|
126
140
|
email:
|
127
141
|
- fnando.vieira@gmail.com
|
@@ -190,6 +204,7 @@ files:
|
|
190
204
|
- lib/browser/meta/safari.rb
|
191
205
|
- lib/browser/meta/tablet.rb
|
192
206
|
- lib/browser/meta/webkit.rb
|
207
|
+
- lib/browser/micro_messenger.rb
|
193
208
|
- lib/browser/middleware.rb
|
194
209
|
- lib/browser/middleware/context.rb
|
195
210
|
- lib/browser/middleware/context/additions.rb
|
@@ -216,6 +231,7 @@ files:
|
|
216
231
|
- lib/browser/testing.rb
|
217
232
|
- lib/browser/uc_browser.rb
|
218
233
|
- lib/browser/version.rb
|
234
|
+
- lib/browser/weibo.rb
|
219
235
|
- search_engines.yml
|
220
236
|
- test/browser_test.rb
|
221
237
|
- test/middleware_test.rb
|
@@ -234,17 +250,20 @@ files:
|
|
234
250
|
- test/unit/console_test.rb
|
235
251
|
- test/unit/device_test.rb
|
236
252
|
- test/unit/firefox_test.rb
|
253
|
+
- test/unit/generic_test.rb
|
237
254
|
- test/unit/ie_test.rb
|
238
255
|
- test/unit/ios_app_test.rb
|
239
256
|
- test/unit/ios_test.rb
|
240
257
|
- test/unit/kindle_test.rb
|
241
258
|
- test/unit/meta_test.rb
|
259
|
+
- test/unit/micro_messenger_test.rb
|
242
260
|
- test/unit/nokia_test.rb
|
243
261
|
- test/unit/opera_test.rb
|
244
262
|
- test/unit/platform_test.rb
|
245
263
|
- test/unit/proxy_test.rb
|
246
264
|
- test/unit/safari_test.rb
|
247
265
|
- test/unit/uc_browser_test.rb
|
266
|
+
- test/unit/weibo_test.rb
|
248
267
|
- test/unit/windows_phone_test.rb
|
249
268
|
- test/unit/windows_test.rb
|
250
269
|
homepage: http://github.com/fnando/browser
|
@@ -289,16 +308,19 @@ test_files:
|
|
289
308
|
- test/unit/console_test.rb
|
290
309
|
- test/unit/device_test.rb
|
291
310
|
- test/unit/firefox_test.rb
|
311
|
+
- test/unit/generic_test.rb
|
292
312
|
- test/unit/ie_test.rb
|
293
313
|
- test/unit/ios_app_test.rb
|
294
314
|
- test/unit/ios_test.rb
|
295
315
|
- test/unit/kindle_test.rb
|
296
316
|
- test/unit/meta_test.rb
|
317
|
+
- test/unit/micro_messenger_test.rb
|
297
318
|
- test/unit/nokia_test.rb
|
298
319
|
- test/unit/opera_test.rb
|
299
320
|
- test/unit/platform_test.rb
|
300
321
|
- test/unit/proxy_test.rb
|
301
322
|
- test/unit/safari_test.rb
|
302
323
|
- test/unit/uc_browser_test.rb
|
324
|
+
- test/unit/weibo_test.rb
|
303
325
|
- test/unit/windows_phone_test.rb
|
304
326
|
- test/unit/windows_test.rb
|