browser 2.3.0 → 2.4.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 +3 -8
- data/CHANGELOG.md +9 -0
- data/README.md +12 -1
- data/Rakefile +1 -1
- data/bot_exceptions.yml +2 -0
- data/bots.yml +6 -2
- data/lib/browser.rb +1 -0
- data/lib/browser/accept_language.rb +5 -1
- data/lib/browser/action_controller.rb +1 -0
- data/lib/browser/aliases.rb +32 -0
- data/lib/browser/alipay.rb +1 -0
- data/lib/browser/base.rb +37 -31
- data/lib/browser/blackberry.rb +1 -0
- data/lib/browser/bot.rb +1 -0
- data/lib/browser/browser.rb +1 -0
- data/lib/browser/chrome.rb +1 -0
- data/lib/browser/detect_version.rb +1 -0
- data/lib/browser/device.rb +2 -1
- data/lib/browser/device/base.rb +1 -0
- data/lib/browser/device/blackberry_playbook.rb +1 -0
- data/lib/browser/device/ipad.rb +1 -0
- data/lib/browser/device/iphone.rb +1 -0
- data/lib/browser/device/ipod_touch.rb +1 -0
- data/lib/browser/device/kindle.rb +1 -0
- data/lib/browser/device/kindle_fire.rb +1 -0
- data/lib/browser/device/playstation3.rb +1 -0
- data/lib/browser/device/playstation4.rb +1 -0
- data/lib/browser/device/psp.rb +1 -0
- data/lib/browser/device/psvita.rb +1 -0
- data/lib/browser/device/surface.rb +1 -0
- data/lib/browser/device/tv.rb +1 -0
- data/lib/browser/device/unknown.rb +1 -0
- data/lib/browser/device/wii.rb +1 -0
- data/lib/browser/device/wiiu.rb +1 -0
- data/lib/browser/device/xbox_360.rb +1 -0
- data/lib/browser/device/xbox_one.rb +1 -0
- data/lib/browser/edge.rb +1 -0
- data/lib/browser/firefox.rb +1 -0
- data/lib/browser/generic.rb +1 -0
- data/lib/browser/internet_explorer.rb +1 -0
- data/lib/browser/meta.rb +1 -0
- data/lib/browser/meta/base.rb +1 -0
- data/lib/browser/meta/device.rb +1 -0
- data/lib/browser/meta/generic_browser.rb +1 -0
- data/lib/browser/meta/id.rb +1 -0
- data/lib/browser/meta/ie.rb +1 -0
- data/lib/browser/meta/ios.rb +1 -0
- data/lib/browser/meta/mobile.rb +1 -0
- data/lib/browser/meta/modern.rb +1 -0
- data/lib/browser/meta/platform.rb +1 -0
- data/lib/browser/meta/proxy.rb +1 -0
- data/lib/browser/meta/safari.rb +1 -0
- data/lib/browser/meta/tablet.rb +1 -0
- data/lib/browser/meta/webkit.rb +1 -0
- data/lib/browser/micro_messenger.rb +1 -0
- data/lib/browser/middleware.rb +1 -0
- data/lib/browser/middleware/context.rb +1 -0
- data/lib/browser/middleware/context/additions.rb +1 -0
- data/lib/browser/middleware/context/url_methods.rb +1 -0
- data/lib/browser/nokia.rb +1 -0
- data/lib/browser/opera.rb +1 -0
- data/lib/browser/phantom_js.rb +1 -0
- data/lib/browser/platform.rb +5 -4
- data/lib/browser/platform/adobe_air.rb +1 -0
- data/lib/browser/platform/android.rb +1 -0
- data/lib/browser/platform/base.rb +1 -0
- data/lib/browser/platform/blackberry.rb +1 -0
- data/lib/browser/platform/chrome_os.rb +1 -0
- data/lib/browser/platform/firefox_os.rb +1 -0
- data/lib/browser/platform/ios.rb +1 -0
- data/lib/browser/platform/linux.rb +1 -0
- data/lib/browser/platform/mac.rb +1 -0
- data/lib/browser/platform/other.rb +1 -0
- data/lib/browser/platform/windows.rb +1 -0
- data/lib/browser/platform/windows_mobile.rb +1 -0
- data/lib/browser/platform/windows_phone.rb +1 -0
- data/lib/browser/qq.rb +1 -0
- data/lib/browser/rails.rb +1 -0
- data/lib/browser/safari.rb +1 -0
- data/lib/browser/testing.rb +1 -0
- data/lib/browser/uc_browser.rb +1 -0
- data/lib/browser/version.rb +2 -1
- data/lib/browser/weibo.rb +1 -0
- data/test/browser_test.rb +5 -1
- data/test/middleware_test.rb +1 -0
- data/test/rails_test.rb +1 -0
- data/test/sample_app.rb +2 -1
- data/test/test_helper.rb +3 -2
- data/test/ua.yml +1 -0
- data/test/ua_bots.yml +4 -0
- data/test/unit/accept_language_test.rb +38 -1
- data/test/unit/adobe_air_test.rb +1 -0
- data/test/unit/aliases_test.rb +42 -0
- data/test/unit/alipay_test.rb +6 -0
- data/test/unit/android_test.rb +1 -0
- data/test/unit/blackberry_test.rb +1 -0
- data/test/unit/bots_test.rb +11 -0
- data/test/unit/chrome_test.rb +11 -0
- data/test/unit/console_test.rb +1 -0
- data/test/unit/device_test.rb +8 -0
- data/test/unit/edge_test.rb +60 -0
- data/test/unit/firefox_test.rb +6 -0
- data/test/unit/generic_test.rb +1 -0
- data/test/unit/{ie_test.rb → internet_explorer_test.rb} +1 -50
- data/test/unit/ios_app_test.rb +1 -0
- data/test/unit/ios_test.rb +1 -0
- data/test/unit/kindle_test.rb +1 -0
- data/test/unit/meta_test.rb +1 -0
- data/test/unit/micro_messenger_test.rb +6 -0
- data/test/unit/nokia_test.rb +6 -0
- data/test/unit/opera_test.rb +11 -0
- data/test/unit/platform_test.rb +3 -0
- data/test/unit/proxy_test.rb +1 -0
- data/test/unit/qq_test.rb +1 -0
- data/test/unit/safari_test.rb +6 -0
- data/test/unit/uc_browser_test.rb +6 -0
- data/test/unit/weibo_test.rb +7 -1
- data/test/unit/windows_phone_test.rb +1 -0
- data/test/unit/windows_test.rb +1 -0
- metadata +10 -6
- data/gemfiles/rails3.gemfile +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0828232944387c4f17fbb21c8898d3d310d76d6
|
4
|
+
data.tar.gz: ada9777fb56e976f0cbe2712b47922f5567c4dea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3bd6be62efd9948c33f9ead9efbb721a416a3273c403d6c81494f8fb0479e7abf531de4e92668e8ecf4426832466013de4f9225de3d3ead056b6772dbd1b813
|
7
|
+
data.tar.gz: 3d01aa934c168838d056632917f8e8a58cd4d9e810b28f9a27d8d4ddd79db52049718eab57e937201fe5d4305e71b8638ef3c92ab1342342b5beb74b46dee87b
|
data/.travis.yml
CHANGED
@@ -2,17 +2,12 @@ language: ruby
|
|
2
2
|
sudo: false
|
3
3
|
cache: bundler
|
4
4
|
rvm:
|
5
|
-
- '2.
|
6
|
-
- '2.
|
7
|
-
- '2.
|
5
|
+
- '2.4.1'
|
6
|
+
- '2.3.4'
|
7
|
+
- '2.2.7'
|
8
8
|
gemfile:
|
9
9
|
- Gemfile
|
10
|
-
- gemfiles/rails3.gemfile
|
11
10
|
- gemfiles/rails4.gemfile
|
12
|
-
matrix:
|
13
|
-
exclude:
|
14
|
-
- rvm: '2.1'
|
15
|
-
gemfile: Gemfile
|
16
11
|
script: bundle exec rake
|
17
12
|
notifications:
|
18
13
|
email: false
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v2.4.0
|
4
|
+
|
5
|
+
- Add Google Drive API, Proximic Spider, NewRelic pinger and SocialRank bots.
|
6
|
+
- Add Pinboard in-app browser to the bot exception list.
|
7
|
+
- All browser detection methods can now compare versions.
|
8
|
+
- All platform detection methods can now compare versions (except `#linux?` and `#firefox_os?`).
|
9
|
+
- Add `browser/aliases`, so you can have methods on the base object (e.g. `browser.mobile?`). See README for instructions.
|
10
|
+
- Remove official support for Rails 3 and Ruby 2.1.
|
11
|
+
|
3
12
|
## v2.3.0
|
4
13
|
|
5
14
|
- Add AWS ELB bot.
|
data/README.md
CHANGED
@@ -116,11 +116,22 @@ browser.platform.windows_touchscreen_desktop?
|
|
116
116
|
browser.platform.windows_vista?
|
117
117
|
browser.platform.windows_wow64?
|
118
118
|
browser.platform.windows_x64?
|
119
|
-
browser.platform.windows_x64?
|
120
119
|
browser.platform.windows_x64_inclusive?
|
121
120
|
browser.platform.windows_xp?
|
122
121
|
```
|
123
122
|
|
123
|
+
### Aliases
|
124
|
+
|
125
|
+
To add aliases like `mobile?` and `tablet?` to the base object (e.g `browser.mobile?`), require the `browser/aliases` file and extend the Browser::Base object like the following:
|
126
|
+
|
127
|
+
```ruby
|
128
|
+
require "browser/aliases"
|
129
|
+
Browser::Base.include(Browser::Aliases)
|
130
|
+
|
131
|
+
browser = Browser.new("Some user agent")
|
132
|
+
browser.mobile? #=> false
|
133
|
+
```
|
134
|
+
|
124
135
|
### What's being detected?
|
125
136
|
|
126
137
|
- For a list of platform detections, check [lib/browser/platform.rb](https://github.com/fnando/browser/blob/master/lib/browser/platform.rb)
|
data/Rakefile
CHANGED
data/bot_exceptions.yml
CHANGED
data/bots.yml
CHANGED
@@ -10,6 +10,7 @@ ahrefsbot: "Ahrefs backlinks research tool"
|
|
10
10
|
alexa: "Alexa Crawler"
|
11
11
|
apache-httpclient: "Java http library"
|
12
12
|
apachebench: "ApacheBench (ab)"
|
13
|
+
apis-google: APIs-Google
|
13
14
|
appengine-google: "Google App Engine"
|
14
15
|
applebot: "Apple Bot"
|
15
16
|
archive.org_bot: "Internet Archive (archive.org)"
|
@@ -33,8 +34,8 @@ check_http: "Nagios monitor"
|
|
33
34
|
cliqzbot: "Cliqzbot"
|
34
35
|
cmradar/0.1: "CMRadar/0.1"
|
35
36
|
coldfusion: "ColdFusion http library"
|
36
|
-
comodo-webinspector-crawler: "Comodo"
|
37
37
|
commoncrawl: "CCBot"
|
38
|
+
comodo-webinspector-crawler: "Comodo"
|
38
39
|
crowsnest: "Crowsnest"
|
39
40
|
curabot: "cura.yt"
|
40
41
|
curl: "curl unix CLI http client"
|
@@ -138,7 +139,8 @@ netcraft: "Netcraft"
|
|
138
139
|
netstate: "netEstate NE Crawler"
|
139
140
|
netvibes: "Personalized dashboard bot"
|
140
141
|
netzcheckbot: "netzcheck"
|
141
|
-
|
142
|
+
newrelicmonitor: "NewRelic monitor"
|
143
|
+
newrelicpinger: "NewRelicPinger"
|
142
144
|
newsme: "newsme"
|
143
145
|
niki-bot: "niki-bot"
|
144
146
|
ning: "NING - Yet Another Twitter Swarmer"
|
@@ -156,6 +158,7 @@ pingdom: "Pingdom monitoring"
|
|
156
158
|
pinterest: "Pinterest"
|
157
159
|
plukkie: "botje.com/plukkie.htm"
|
158
160
|
privacyawarebot: "PrivacyAwareBot"
|
161
|
+
proximic: "Proximic Spider"
|
159
162
|
psbot-page: "Picsearch"
|
160
163
|
publiclibraryarchive.org: "publiclibraryarchive.org"
|
161
164
|
pycurl: "Python http library"
|
@@ -189,6 +192,7 @@ slack: "Slackbot-LinkExpanding"
|
|
189
192
|
slackbot: "Slack Bot"
|
190
193
|
slurp: "Yahoo spider"
|
191
194
|
smtbot: "SimilarTech"
|
195
|
+
socialrank: "SocialRankIOBot"
|
192
196
|
sogou: "Chinese search engine"
|
193
197
|
spbot: "OpenLinkProfiler"
|
194
198
|
spider: "generic web spider"
|
data/lib/browser.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Browser
|
3
4
|
class AcceptLanguage
|
4
5
|
def self.languages
|
@@ -32,7 +33,10 @@ module Browser
|
|
32
33
|
end
|
33
34
|
|
34
35
|
def code
|
35
|
-
@code ||=
|
36
|
+
@code ||= begin
|
37
|
+
code = part[/\A([^-;]+)/, 1]
|
38
|
+
code.downcase if code
|
39
|
+
end
|
36
40
|
end
|
37
41
|
|
38
42
|
def region
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "browser"
|
4
|
+
require "forwardable"
|
5
|
+
|
6
|
+
module Browser
|
7
|
+
module Aliases
|
8
|
+
PLATFORM_ALIASES = %w[
|
9
|
+
adobe_air? android? blackberry? chrome_os? firefox_os? ios? ios_app?
|
10
|
+
ios_webview? linux? mac? windows10? windows7? windows8? windows8_1?
|
11
|
+
windows? windows_mobile? windows_phone? windows_rt?
|
12
|
+
windows_touchscreen_desktop? windows_vista? windows_wow64? windows_x64?
|
13
|
+
windows_x64_inclusive? windows_xp?
|
14
|
+
].freeze
|
15
|
+
|
16
|
+
DEVICE_ALIASES = %w[
|
17
|
+
blackberry_playbook? console? ipad? iphone? ipod_touch? kindle?
|
18
|
+
kindle_fire? mobile? nintendo? nintendo_wii? nintendo_wiiu? playbook?
|
19
|
+
playstation3? playstation4? playstation? playstation_vita? ps3? ps4? psp?
|
20
|
+
psp_vita? silk? surface? tablet? tv? vita? wii? wiiu? xbox? xbox_360?
|
21
|
+
xbox_one?
|
22
|
+
].freeze
|
23
|
+
|
24
|
+
def self.included(target)
|
25
|
+
target.class_eval do
|
26
|
+
extend Forwardable
|
27
|
+
def_delegators :platform, *PLATFORM_ALIASES
|
28
|
+
def_delegators :device, *DEVICE_ALIASES
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/browser/alipay.rb
CHANGED
data/lib/browser/base.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Browser
|
3
4
|
class Base
|
4
5
|
include DetectVersion
|
@@ -57,12 +58,12 @@ module Browser
|
|
57
58
|
# Detect if browser is Microsoft Internet Explorer.
|
58
59
|
def ie?(expected_version = nil)
|
59
60
|
InternetExplorer.new(ua).match? &&
|
60
|
-
detect_version?(
|
61
|
+
detect_version?(full_version, expected_version)
|
61
62
|
end
|
62
63
|
|
63
64
|
# Detect if browser is Microsoft Edge.
|
64
|
-
def edge?
|
65
|
-
Edge.new(ua).match?
|
65
|
+
def edge?(expected_version = nil)
|
66
|
+
Edge.new(ua).match? && detect_version?(full_version, expected_version)
|
66
67
|
end
|
67
68
|
|
68
69
|
def compatibility_view?
|
@@ -78,23 +79,26 @@ module Browser
|
|
78
79
|
end
|
79
80
|
|
80
81
|
# Detect if browser is WebKit-based.
|
81
|
-
def webkit?
|
82
|
-
ua =~ /AppleWebKit/i &&
|
82
|
+
def webkit?(expected_version = nil)
|
83
|
+
ua =~ /AppleWebKit/i &&
|
84
|
+
!edge? &&
|
85
|
+
detect_version?(webkit_full_version, expected_version)
|
83
86
|
end
|
84
87
|
|
85
88
|
# Detect if browser is QuickTime
|
86
|
-
def quicktime?
|
87
|
-
ua =~ /QuickTime/i
|
89
|
+
def quicktime?(expected_version = nil)
|
90
|
+
ua =~ /QuickTime/i && detect_version?(full_version, expected_version)
|
88
91
|
end
|
89
92
|
|
90
93
|
# Detect if browser is Apple CoreMedia.
|
91
|
-
def core_media?
|
92
|
-
ua =~ /CoreMedia/
|
94
|
+
def core_media?(expected_version = nil)
|
95
|
+
ua =~ /CoreMedia/ && detect_version?(full_version, expected_version)
|
93
96
|
end
|
94
97
|
|
95
98
|
# Detect if browser is PhantomJS
|
96
|
-
def phantom_js?
|
97
|
-
PhantomJS.new(ua).match?
|
99
|
+
def phantom_js?(expected_version = nil)
|
100
|
+
PhantomJS.new(ua).match? &&
|
101
|
+
detect_version?(full_version, expected_version)
|
98
102
|
end
|
99
103
|
|
100
104
|
# Detect if browser is Safari.
|
@@ -107,53 +111,55 @@ module Browser
|
|
107
111
|
end
|
108
112
|
|
109
113
|
# Detect if browser is Firefox.
|
110
|
-
def firefox?
|
111
|
-
Firefox.new(ua).match?
|
114
|
+
def firefox?(expected_version = nil)
|
115
|
+
Firefox.new(ua).match? && detect_version?(full_version, expected_version)
|
112
116
|
end
|
113
117
|
|
114
118
|
# Detect if browser is Chrome.
|
115
|
-
def chrome?
|
116
|
-
Chrome.new(ua).match?
|
119
|
+
def chrome?(expected_version = nil)
|
120
|
+
Chrome.new(ua).match? && detect_version?(full_version, expected_version)
|
117
121
|
end
|
118
122
|
|
119
123
|
# Detect if browser is Opera.
|
120
|
-
def opera?
|
121
|
-
Opera.new(ua).match?
|
124
|
+
def opera?(expected_version = nil)
|
125
|
+
Opera.new(ua).match? && detect_version?(full_version, expected_version)
|
122
126
|
end
|
123
127
|
|
124
128
|
# Detect if browser is Yandex.
|
125
|
-
def yandex?
|
126
|
-
ua =~ /YaBrowser/
|
129
|
+
def yandex?(expected_version = nil)
|
130
|
+
ua =~ /YaBrowser/ && detect_version?(full_version, expected_version)
|
127
131
|
end
|
128
132
|
|
129
133
|
# Detect if browser is UCBrowser.
|
130
|
-
def uc_browser?
|
131
|
-
UCBrowser.new(ua).match?
|
134
|
+
def uc_browser?(expected_version = nil)
|
135
|
+
UCBrowser.new(ua).match? &&
|
136
|
+
detect_version?(full_version, expected_version)
|
132
137
|
end
|
133
138
|
|
134
139
|
# Detect if browser is Nokia S40 Ovi Browser.
|
135
|
-
def nokia?
|
136
|
-
Nokia.new(ua).match?
|
140
|
+
def nokia?(expected_version = nil)
|
141
|
+
Nokia.new(ua).match? && detect_version?(full_version, expected_version)
|
137
142
|
end
|
138
143
|
|
139
144
|
# Detect if browser is MicroMessenger.
|
140
|
-
def micro_messenger?
|
141
|
-
MicroMessenger.new(ua).match?
|
145
|
+
def micro_messenger?(expected_version = nil)
|
146
|
+
MicroMessenger.new(ua).match? &&
|
147
|
+
detect_version?(full_version, expected_version)
|
142
148
|
end
|
143
149
|
|
144
150
|
alias_method :wechat?, :micro_messenger?
|
145
151
|
|
146
|
-
def weibo?
|
147
|
-
Weibo.new(ua).match?
|
152
|
+
def weibo?(expected_version = nil)
|
153
|
+
Weibo.new(ua).match? && detect_version?(full_version, expected_version)
|
148
154
|
end
|
149
155
|
|
150
|
-
def alipay?
|
151
|
-
Alipay.new(ua).match?
|
156
|
+
def alipay?(expected_version = nil)
|
157
|
+
Alipay.new(ua).match? && detect_version?(full_version, expected_version)
|
152
158
|
end
|
153
159
|
|
154
160
|
# Detect if browser is Opera Mini.
|
155
|
-
def opera_mini?
|
156
|
-
ua =~ /Opera Mini/
|
161
|
+
def opera_mini?(expected_version = nil)
|
162
|
+
ua =~ /Opera Mini/ && detect_version?(full_version, expected_version)
|
157
163
|
end
|
158
164
|
|
159
165
|
def webkit_full_version
|
data/lib/browser/blackberry.rb
CHANGED
data/lib/browser/bot.rb
CHANGED
data/lib/browser/browser.rb
CHANGED
data/lib/browser/chrome.rb
CHANGED
data/lib/browser/device.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require "browser/device/base"
|
3
4
|
require "browser/device/unknown"
|
4
5
|
require "browser/device/ipad"
|
@@ -39,8 +40,8 @@ module Browser
|
|
39
40
|
PlayStation3,
|
40
41
|
PSVita,
|
41
42
|
PSP,
|
42
|
-
Iphone,
|
43
43
|
Ipad,
|
44
|
+
Iphone,
|
44
45
|
IpodTouch,
|
45
46
|
Unknown
|
46
47
|
]
|
data/lib/browser/device/base.rb
CHANGED
data/lib/browser/device/ipad.rb
CHANGED