browser 3.0.3 → 4.0.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
  SHA256:
3
- metadata.gz: 35cb9e029740dd22fac2f08ea933fb541b914ddc3d437f49e2402f68be7aecb3
4
- data.tar.gz: 534a21b9b6892178c02976d19fe8ef81e9746783ac87469239efb9e8033bfaeb
3
+ metadata.gz: 75c57477baeccabb50b2c056dcd65d33beb39b2bfb066338062a0d58f372648d
4
+ data.tar.gz: a2a7ae9958798ab7e04545101087f2c06f2cc241e00eef38c04eb478e477f015
5
5
  SHA512:
6
- metadata.gz: fe9062f778c871766bddce4738c63ad005e0fc6310c46b0505f78da1c304e5d2f0359d8c2685727203876f8b83bf7ee06fc7dfa6b2f5fb6da719cf60bd5f80a7
7
- data.tar.gz: ecce9f6468c7e5cfb11e47aeeaa68c44d8be5ad6b4e6e34cc9f64721dbaf0adae1514cb8b57097ec679481da7286713468fa4ac88de397190179bbf13ef42331
6
+ metadata.gz: f01337cf351ba371d85a37ae957aa04f71854103c2fad413583a6258d66a8218595528464e1aa9f6e273824340c9ca29fe7048ad676a73dbc69dcb8220ecf2f8
7
+ data.tar.gz: d3729b88eb7e6a0c92a2d9f14d9b2c073fe782f6045c6ffb74f74766bf353b92f3660154e434c6020a6870810843c1948e658a1c87f1f15454b1fbec7bc135b4
@@ -27,4 +27,4 @@
27
27
 
28
28
  ## Report
29
29
 
30
- [Visit <http://user-agent.herokuapp.com> and paste the URL here]
30
+ [Visit <https://user-agent.herokuapp.com> and paste the URL here]
@@ -27,3 +27,9 @@ Style/Alias:
27
27
 
28
28
  Lint/RedundantCopDisableDirective:
29
29
  Enabled: false
30
+
31
+ Metrics/AbcSize:
32
+ Enabled: false
33
+
34
+ Metrics/CyclomaticComplexity:
35
+ Enabled: false
@@ -2,11 +2,17 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
- - Nothing yet.
5
+ - Add Chrome Lighthouse to bot list.
6
+ - Add SeobilityBot to the bot list.
7
+ - Detect Mac-based platforms differently, depending on the version; "Mac OS X"
8
+ will be returned for versions prior to 10.12, and "macOS" for newer versions.
9
+ - Remove `Browser.modern_rules` and `Browser::Base#modern?`.
10
+ - Add DuckDuckGo browser.
6
11
 
7
12
  # 3.0.3
8
13
 
9
- - Deprecate `Browser.modern_rules` and `Browser::Base#modern?`. Theses methods will be removed on the next major released, or by June 1st 2020.
14
+ - Deprecate `Browser.modern_rules` and `Browser::Base#modern?`. Theses methods
15
+ will be removed on the next major released, or by June 1st 2020.
10
16
 
11
17
  ## 3.0.2
12
18
 
@@ -21,23 +27,32 @@
21
27
  - Add ArchiveTeam's ArchiveBot to the bot list.
22
28
  - Fix QQ Browser detection.
23
29
  - Update modern rules.
24
- - You can now define new bot matchers by adding a callable object to `Browser::Bot.matchers`.
30
+ - You can now define new bot matchers by adding a callable object to
31
+ `Browser::Bot.matchers`.
25
32
  - Fix `browser.yandex?` and `browser.sputnik?`.
26
- - [BREAKING CHANGE] Removed methods to enable the bot's empty user agent detection (`Browser::Bot.detect_empty_ua!` and `Browser::Bot.detect_empty_ua?`).
27
- - [BREAKING CHANGE] Bot detection is now more aggressive by default. It matches empty user agents, anything that matches `crawl|fetch|search|monitoring|spider|bot`, and anything listed under https://github.com/fnando/browser/blob/master/bots.yml.
33
+ - [BREAKING CHANGE] Removed methods to enable the bot's empty user agent
34
+ detection (`Browser::Bot.detect_empty_ua!` and
35
+ `Browser::Bot.detect_empty_ua?`).
36
+ - [BREAKING CHANGE] Bot detection is now more aggressive by default. It matches
37
+ empty user agents, anything that matches
38
+ `crawl|fetch|search|monitoring|spider|bot`, and anything listed under
39
+ https://github.com/fnando/browser/blob/master/bots.yml.
28
40
  - Add Jaunt to the bot list.
29
41
 
30
42
  ## 2.7.1
31
43
 
32
- - Handle Snapchat user agents that have a space or an empty string instead of a slash before the version.
44
+ - Handle Snapchat user agents that have a space or an empty string instead of a
45
+ slash before the version.
33
46
  - Fix iOS 10+ version detection.
34
- - Add fallback versions for instagram and snapchat to avoid NoMethodErrors on unexpected user agents.
47
+ - Add fallback versions for instagram and snapchat to avoid NoMethodErrors on
48
+ unexpected user agents.
35
49
 
36
50
  ## 2.7.0
37
51
 
38
52
  - Add more Slack bots.
39
53
  - Handle instagram user agents that have a slash instead of a space.
40
- - Add `Browser::Bot.why?(ua)` to help debugging why a user agent is considered bot.
54
+ - Add `Browser::Bot.why?(ua)` to help debugging why a user agent is considered
55
+ bot.
41
56
  - Promote Snapchat to a browser (it was detected as a bot previously).
42
57
  - Detect Edge based on Chrome correctly.
43
58
  - Improve Yandex detection.
@@ -53,7 +68,8 @@
53
68
 
54
69
  - Add GarlikCrawler, ImplisenseBot and WikiDo bots.
55
70
  - Add Mastodon URL expander bot.
56
- - Add eZ Publish Link Validator, GermCrawler, Pu_iN Crawler, ZoomBot, and ZoominfoBot bots.
71
+ - Add eZ Publish Link Validator, GermCrawler, Pu_iN Crawler, ZoomBot, and
72
+ ZoominfoBot bots.
57
73
  - Add Datanyze bot.
58
74
  - Add support for Instagram in-app browser.
59
75
  - Add Updown.io monitor bot.
@@ -75,13 +91,13 @@
75
91
  - Add Jooble bot.
76
92
  - Add Fyre bot.
77
93
  - Drop Rails 4 official support.
78
- - Fix accept-language sorting (If HTTP-header has value `en,fr`—without qualities—the first language should be `en` instead of `fr`).
94
+ - Fix accept-language sorting (If HTTP-header has value `en,fr`—without
95
+ qualities—the first language should be `en` instead of `fr`).
79
96
  - Ignore malformed strings when comparing versions.
80
97
  - Fix Facebook detection on newer apps.
81
98
  - Change precedence for bot detection when common libs are used.
82
99
  - Add Yandex's search browser to the exception list.
83
100
 
84
-
85
101
  ## v2.5.3
86
102
 
87
103
  - Add Google Site Verification to the bot list.
@@ -122,8 +138,10 @@
122
138
  - Add Google Drive API, Proximic Spider, NewRelic pinger and SocialRank bots.
123
139
  - Add Pinboard in-app browser to the bot exception list.
124
140
  - All browser detection methods can now compare versions.
125
- - All platform detection methods can now compare versions (except `#linux?` and `#firefox_os?`).
126
- - Add `browser/aliases`, so you can have methods on the base object (e.g. `browser.mobile?`). See README for instructions.
141
+ - All platform detection methods can now compare versions (except `#linux?` and
142
+ `#firefox_os?`).
143
+ - Add `browser/aliases`, so you can have methods on the base object (e.g.
144
+ `browser.mobile?`). See README for instructions.
127
145
  - Remove official support for Rails 3 and Ruby 2.1.
128
146
 
129
147
  ## v2.3.0
@@ -154,7 +172,8 @@
154
172
 
155
173
  ## v2.0.3
156
174
 
157
- - Fix issue with version detection when no actual version is provided (i.e. the user agent doesn't have any version information).
175
+ - Fix issue with version detection when no actual version is provided (i.e. the
176
+ user agent doesn't have any version information).
158
177
 
159
178
  ## v2.0.2
160
179
 
@@ -167,9 +186,12 @@
167
186
 
168
187
  ## v2.0.0
169
188
 
170
- - `Browser#platform` now returns instance of `Browser::Platform`, instead of a `String`. It contains information about the platform (software).
171
- - `Browser#device` was added. It returns information about the device (hardware).
172
- - `Browser#accept_language` now returns a list of `Browser::AcceptLanguage` objects.
189
+ - `Browser#platform` now returns instance of `Browser::Platform`, instead of a
190
+ `String`. It contains information about the platform (software).
191
+ - `Browser#device` was added. It returns information about the device
192
+ (hardware).
193
+ - `Browser#accept_language` now returns a list of `Browser::AcceptLanguage`
194
+ objects.
173
195
  - `Browser#bot` now returns a `Browser::Bot` instance.
174
196
  - Safari running as web app mode is not recognized as Safari anymore.
175
197
  - ruby-2.3+ will always activate frozen strings.
data/README.md CHANGED
@@ -25,6 +25,7 @@ browser = Browser.new("Some User Agent", accept_language: "en-us")
25
25
  browser.bot?
26
26
  browser.chrome?
27
27
  browser.core_media?
28
+ browser.duck_duck_go?
28
29
  browser.edge? # Newest MS browser
29
30
  browser.electron? # Electron Framework
30
31
  browser.firefox?
@@ -153,12 +154,12 @@ To detect whether a browser can be considered as modern or not, create a method
153
154
  # like in `Browser.new(user_agent, accept_language: language)`.
154
155
  def modern_browser?(browser)
155
156
  [
156
- browser.chrome? && browser.version.to_i >= 65,
157
- browser.safari? && browser.version.to_i >= 10,
158
- browser.firefox? && browser.version.to_i >= 52,
159
- browser.ie? && browser.version.to_i >= 11 && !browser.compatibility_view?,
160
- browser.edge? && browser.version.to_i >= 15,
161
- browser.opera? && browser.version.to_i >= 50,
157
+ browser.chrome?(">= 65"),
158
+ browser.safari?(">= 10"),
159
+ browser.firefox?(">= 52"),
160
+ browser.ie?(">= 11") && !browser.compatibility_view?,
161
+ browser.edge?(">= 15"),
162
+ browser.opera?(">= 50"),
162
163
  browser.facebook?
163
164
  && browser.safari_webapp_mode?
164
165
  && browser.webkit_full_version.to_i >= 602
data/bots.yml CHANGED
@@ -38,6 +38,7 @@ buzzbot: "Buzzbot"
38
38
  buzztalk: "buzztalk"
39
39
  catchbot: "CatchBot (catchbot.com)"
40
40
  check_http: "Nagios monitor"
41
+ chrome_lighthouse: "Chrome-Lighthouse"
41
42
  cipacrawler: "CipaCrawler"
42
43
  cliqzbot: "Cliqzbot"
43
44
  cloudflare: "CloudFlare-AlwaysOnline"
@@ -203,6 +204,7 @@ searchmetricsbot: "SearchmetricsBot"
203
204
  semanticbot: "Semanticbot"
204
205
  semrushbot: "SEO analysis bot"
205
206
  seo-audit: "seo-audit-check-bot"
207
+ seobilitybot: "SeobilityBot"
206
208
  seodiver: "SEOdiver"
207
209
  seokicks: "SEOKicks"
208
210
  seznambot: "SeznamBot"
@@ -50,16 +50,6 @@ module Browser
50
50
  @device ||= Device.new(ua)
51
51
  end
52
52
 
53
- # Return true if browser is modern (Webkit, Firefox 17+, IE9+, Opera 12+).
54
- def modern?
55
- warn <<~TEXT
56
- Browser::Base#modern? is now deprecated.
57
- Check https://github.com/fnando/browser/issues/435 for details.
58
- TEXT
59
-
60
- Browser.modern_rules.any? {|rule| rule === self } # rubocop:disable Style/CaseEquality
61
- end
62
-
63
53
  # Detect if browser is Microsoft Internet Explorer.
64
54
  def ie?(expected_version = nil)
65
55
  InternetExplorer.new(ua).match? &&
@@ -197,6 +187,11 @@ module Browser
197
187
  ua =~ /Opera Mini/ && detect_version?(full_version, expected_version)
198
188
  end
199
189
 
190
+ # Detect if browser is DuckDuckGo.
191
+ def duck_duck_go?(expected_version = nil)
192
+ ua =~ /DuckDuckGo/ && detect_version?(full_version, expected_version)
193
+ end
194
+
200
195
  def webkit_full_version
201
196
  ua[%r{AppleWebKit/([\d.]+)}, 1] || "0.0"
202
197
  end
@@ -30,6 +30,7 @@ require_relative "instagram"
30
30
  require_relative "yandex"
31
31
  require_relative "sputnik"
32
32
  require_relative "snapchat"
33
+ require_relative "duck_duck_go"
33
34
 
34
35
  require_relative "bot"
35
36
  require_relative "bot/empty_user_agent_matcher"
@@ -70,6 +71,7 @@ module Browser
70
71
  Electron, # must be placed before Chrome and Safari
71
72
  Yandex, # must be placed before Chrome and Safari
72
73
  Sputnik, # must be placed before Chrome and Safari
74
+ DuckDuckGo, # must be placed before Chrome and Safari
73
75
  Chrome,
74
76
  Safari,
75
77
  MicroMessenger,
@@ -77,29 +79,6 @@ module Browser
77
79
  ]
78
80
  end
79
81
 
80
- # Define the rules which define a modern browser.
81
- # A rule must be a proc/lambda or any object that implements the method
82
- # === and accepts the browser object.
83
- #
84
- # To redefine all rules, clear the existing rules before adding your own.
85
- #
86
- # # Only Chrome Canary is considered modern.
87
- # Browser.modern_rules.clear
88
- # Browser.modern_rules << -> b { b.chrome? && b.version >= "37" }
89
- #
90
- def self.modern_rules
91
- @modern_rules ||= []
92
- end
93
-
94
- modern_rules.tap do |rules|
95
- rules << ->(b) { b.chrome? && b.version.to_i >= 65 }
96
- rules << ->(b) { b.safari? && b.version.to_i >= 10 }
97
- rules << ->(b) { b.firefox? && b.version.to_i >= 52 }
98
- rules << ->(b) { b.ie? && b.version.to_i >= 11 && !b.compatibility_view? }
99
- rules << ->(b) { b.edge? && b.version.to_i >= 15 }
100
- rules << ->(b) { b.opera? && b.version.to_i >= 50 }
101
- end
102
-
103
82
  def self.new(user_agent, **kwargs)
104
83
  matchers
105
84
  .map {|klass| klass.new(user_agent || EMPTY_STRING, **kwargs) }
@@ -21,9 +21,12 @@ module Browser
21
21
 
22
22
  def match?
23
23
  ua =~ /Chrome|CriOS/ &&
24
- ua !~ /PhantomJS|FxiOS|YaBrowser|SputnikBrowser|ArchiveBot/ &&
24
+ ua !~ /PhantomJS|FxiOS|ArchiveBot/ &&
25
25
  !opera? &&
26
- !edge?
26
+ !edge? &&
27
+ !duck_duck_go? &&
28
+ !yandex? &&
29
+ !sputnik?
27
30
  end
28
31
  end
29
32
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Browser
4
+ class DuckDuckGo < Base
5
+ def id
6
+ :duckduckgo
7
+ end
8
+
9
+ def name
10
+ "DuckDuckGo"
11
+ end
12
+
13
+ def full_version
14
+ ua[%r{DuckDuckGo/([\d.]+)}, 1] ||
15
+ "0.0"
16
+ end
17
+
18
+ def match?
19
+ ua =~ /DuckDuckGo/
20
+ end
21
+ end
22
+ end
@@ -6,7 +6,6 @@ require_relative "meta/id"
6
6
  require_relative "meta/ie"
7
7
  require_relative "meta/ios"
8
8
  require_relative "meta/mobile"
9
- require_relative "meta/modern"
10
9
  require_relative "meta/platform"
11
10
  require_relative "meta/proxy"
12
11
  require_relative "meta/safari"
@@ -10,7 +10,6 @@ module Browser
10
10
  IE,
11
11
  IOS,
12
12
  Mobile,
13
- Modern,
14
13
  Platform,
15
14
  Proxy,
16
15
  Safari,
@@ -45,7 +45,7 @@ module Browser
45
45
 
46
46
  def subject
47
47
  @subject ||= self.class.matchers
48
- .map {|matcher| matcher.new(ua) }
48
+ .map {|matcher| matcher.new(ua, self) }
49
49
  .find(&:match?)
50
50
  end
51
51
 
@@ -3,10 +3,11 @@
3
3
  module Browser
4
4
  class Platform
5
5
  class Base
6
- attr_reader :ua
6
+ attr_reader :ua, :platform
7
7
 
8
- def initialize(ua)
8
+ def initialize(ua, platform = nil)
9
9
  @ua = ua
10
+ @platform = platform
10
11
  end
11
12
 
12
13
  def match?
@@ -8,7 +8,9 @@ module Browser
8
8
  end
9
9
 
10
10
  def name
11
- "Macintosh"
11
+ return "macOS" if platform.mac?(">= 10.12")
12
+
13
+ "Mac OS X"
12
14
  end
13
15
 
14
16
  def id
@@ -18,7 +18,13 @@ module Browser
18
18
  end
19
19
 
20
20
  def match?
21
- ua =~ /Safari/ && ua !~ /Chrome|CriOS|PhantomJS|FxiOS|YaBrowser/
21
+ ua =~ /Safari/ &&
22
+ ua !~ /PhantomJS|FxiOS/ &&
23
+ !edge? &&
24
+ !chrome? &&
25
+ !duck_duck_go? &&
26
+ !yandex? &&
27
+ !sputnik?
22
28
  end
23
29
  end
24
30
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Browser
4
- VERSION = "3.0.3"
4
+ VERSION = "4.0.0"
5
5
  end
@@ -32,6 +32,8 @@ CHROME: "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/53
32
32
  CHROME_OS: "Mozilla/5.0 (X11; CrOS x86_64 3701.81.0) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.57 Safari/537.31."
33
33
  COREMEDIA: "Apple Mac OS X v10.6.4 CoreMedia v1.0.0.10F569"
34
34
  CUSTOM_APP: "Our App 0.0.1 (Linux; Android 4.0.3; HTC Ruby Build/IML74K; en_CA)"
35
+ DUCKDUCKGO_BROWSER_IOS: "Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 DuckDuckGo/7"
36
+ DUCKDUCKGO_BROWSER_ANDROID: Mozilla/5.0 (Linux; Android 10) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.96 Mobile Safari/537.36 DuckDuckGo/5"
35
37
  ELECTRON: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Electron/1.4.12 Safari/537.36"
36
38
  FACEBOOK: Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_3 like Mac OS X) AppleWebKit/603.3.8 (KHTML, like Gecko) Mobile/14G60 [FBAN/FBIOS;FBAV/135.0.0.45.90;FBBV/66877072;FBDV/iPhone9,3;FBMD/iPhone;FBSN/iOS;FBSV/10.3.3;FBSS/2;FBCR/AT&T;FBID/phone;FBLC/en_US;FBOP/5;FBRV/0]
37
39
  FACEBOOK_ANDROID: "Mozilla/5.0 (Linux; Android 9; ONEPLUS A6003 Build/PKQ1.180716.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/73.0.3683.90 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/214.0.0.43.83;]"
@@ -77,6 +79,8 @@ KINDLE_FIRE: "Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Kindle Fire Build/GIN
77
79
  KINDLE_FIRE_HD: "Mozilla/5.0 (Linux; U; en-us; KFTT Build/IML74K) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.4 Safari/535.19 Silk-Accelerated=true"
78
80
  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"
79
81
  LUMIA800: "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; XBLWP7; ZuneWP7"
82
+ MAC_OS: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Safari/605.1.15"
83
+ MAC_OSX: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9"
80
84
  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"
81
85
  MIDP: MIDP-2.0
82
86
  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"
@@ -13,6 +13,7 @@ BINGBOT: "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm
13
13
  BINGPREVIEW: "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534+ (KHTML, like Gecko) BingPreview/1.0b"
14
14
  BUBING: "BUbiNG (+http://law.di.unimi.it/BUbiNG.html)"
15
15
  BUZZBOT: "Buzzbot/1.0 (Buzzbot; http://www.buzzstream.com; buzzbot@buzzstream.com)"
16
+ CHROME_LIGHTHOUSE: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.4 (KHTML, like Gecko; Google Page Speed Insights) Chrome-Lighthouse"
16
17
  CIPACRAWLER: "CipaCrawler/3.0 (info@domaincrawler.com; http://www.domaincrawler.com/www.example.com)"
17
18
  CLOUDFLARE: "Mozilla/5.0 (compatible; CloudFlare-AlwaysOnline/1.0; +http://www.cloudflare.com/always-online) AppleWebKit/534.34"
18
19
  COMMONCRAWL: "CCBot/2.0 (http://commoncrawl.org/faq/)"
@@ -68,6 +69,7 @@ SCOUT_URL_MONITOR: ScoutURLMonitor/6.2.2
68
69
  SCRAPY: "Scrapy/0.18.4 (+http://scrapy.org)"
69
70
  SEMANTICBOT: "Mozilla/5.0 (compatible; Semanticbot/1.0; +http://sempi.tech/bot.html)"
70
71
  SEO_AUDIT: "Mozilla/5.0 (compatible; seo-audit-check-bot/1.0)"
72
+ SEOBILITYBOT: "SeobilityBot (SEO Tool; https://www.seobility.net/sites/bot.html)"
71
73
  SEODIVER: "Mozilla/5.0 (compatible; SEOdiver/1.0; +http://www.seodiver.com/bot)"
72
74
  SEOKICKS: "Mozilla/5.0 (compatible; SEOkicks-Robot; +http://www.seokicks.de/robot.html)"
73
75
  SISTRIX: "Mozilla/5.0 (compatible; SISTRIX Crawler; http://crawler.sistrix.net/)"
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class DuckDuckGoTest < Minitest::Test
6
+ test "detects DuckDuckGo on iOS device" do
7
+ browser = Browser.new(Browser["DUCKDUCKGO_BROWSER_IOS"])
8
+ assert browser.duck_duck_go?
9
+ refute browser.safari?
10
+ refute browser.chrome?
11
+ assert browser.webkit?
12
+ assert_equal "DuckDuckGo", browser.name
13
+ assert_equal :duckduckgo, browser.id
14
+ end
15
+
16
+ test "detects DuckDuckGo on Android device" do
17
+ browser = Browser.new(Browser["DUCKDUCKGO_BROWSER_ANDROID"])
18
+ assert browser.duck_duck_go?
19
+ refute browser.safari?
20
+ refute browser.chrome?
21
+ assert_equal "DuckDuckGo", browser.name
22
+ assert_equal :duckduckgo, browser.id
23
+ end
24
+
25
+ test "detects correct version" do
26
+ browser = Browser.new(Browser["DUCKDUCKGO_BROWSER_IOS"])
27
+ assert_equal "7", browser.full_version
28
+ assert_equal "7", browser.version
29
+ end
30
+
31
+ test "detects version by range" do
32
+ browser = Browser.new(Browser["DUCKDUCKGO_BROWSER_IOS"])
33
+ assert browser.duck_duck_go?(%w[>=7 <8])
34
+ end
35
+ end
@@ -104,7 +104,7 @@ class PlatformTest < Minitest::Test
104
104
  test "detect mac" do
105
105
  platform = Browser::Platform.new(Browser["SAFARI"])
106
106
 
107
- assert_equal "Macintosh", platform.name
107
+ assert_equal "Mac OS X", platform.name
108
108
  assert_equal :mac, platform.id
109
109
  assert platform.mac?
110
110
  assert_equal "10.6.4", platform.version
@@ -116,6 +116,11 @@ class PlatformTest < Minitest::Test
116
116
  assert_equal "0", platform.version
117
117
  end
118
118
 
119
+ test "detect mac names" do
120
+ assert_equal "Mac OS X", Browser::Platform.new(Browser["MAC_OSX"]).name
121
+ assert_equal "macOS", Browser::Platform.new(Browser["MAC_OS"]).name
122
+ end
123
+
119
124
  test "detect firefox os" do
120
125
  platform = Browser::Platform.new(Browser["FIREFOX_OS"])
121
126
 
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: 3.0.3
4
+ version: 4.0.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: 2020-01-10 00:00:00.000000000 Z
11
+ date: 2020-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -221,6 +221,7 @@ files:
221
221
  - lib/browser/device/wiiu.rb
222
222
  - lib/browser/device/xbox_360.rb
223
223
  - lib/browser/device/xbox_one.rb
224
+ - lib/browser/duck_duck_go.rb
224
225
  - lib/browser/edge.rb
225
226
  - lib/browser/electron.rb
226
227
  - lib/browser/facebook.rb
@@ -236,7 +237,6 @@ files:
236
237
  - lib/browser/meta/ie.rb
237
238
  - lib/browser/meta/ios.rb
238
239
  - lib/browser/meta/mobile.rb
239
- - lib/browser/meta/modern.rb
240
240
  - lib/browser/meta/platform.rb
241
241
  - lib/browser/meta/proxy.rb
242
242
  - lib/browser/meta/safari.rb
@@ -295,6 +295,7 @@ files:
295
295
  - test/unit/chrome_test.rb
296
296
  - test/unit/console_test.rb
297
297
  - test/unit/device_test.rb
298
+ - test/unit/duck_duck_go_test.rb
298
299
  - test/unit/edge_test.rb
299
300
  - test/unit/electron_test.rb
300
301
  - test/unit/facebook_test.rb
@@ -364,6 +365,7 @@ test_files:
364
365
  - test/unit/chrome_test.rb
365
366
  - test/unit/console_test.rb
366
367
  - test/unit/device_test.rb
368
+ - test/unit/duck_duck_go_test.rb
367
369
  - test/unit/edge_test.rb
368
370
  - test/unit/electron_test.rb
369
371
  - test/unit/facebook_test.rb
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Browser
4
- module Meta
5
- class Modern < Base
6
- def meta
7
- "modern" if browser.modern?
8
- end
9
- end
10
- end
11
- end