user_agent_parser 2.3.2 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of user_agent_parser might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b6e1552de9b5a79f538c36d78e34b049460aa0e6
4
- data.tar.gz: 308969122b93727352654432bdd6b41a3a6fdccf
3
+ metadata.gz: 862bbfc92a30de199a32fd1dbebae607551298fa
4
+ data.tar.gz: 303212057c5fad5ce4279a21a966ec27bae860a1
5
5
  SHA512:
6
- metadata.gz: 702a8bfbab57caa023acd6492573566e5e5a13c1320c183475cb19914dc5e15dbd44b521076bc9f57c7fd20702ddb2e264ed5e4e1451dccb44cfd87099b53ba9
7
- data.tar.gz: ce9d88ce53afa4152729ec77d85d3d462c23db2359c22993f2618492287275a2ffa3710394aea17691bff2d61c683e3ea34ede8bff5fadd862705b5d9b6a9e8b
6
+ metadata.gz: 023e8a39eed689f3a0dbfb958ad90e0023fe4f469fae924248e7eda016930e1519428ebeb087e99f92777cbb7dbce1a468143ab3399a3bf6b0476384e055e448
7
+ data.tar.gz: 70978a580d745b38fe07af2e4580696b4fc6200018e522261bd19ec13b3748a6e5d0742002104eed17667e4f00e29625ae1ca902303893577b339c616fe94709
data/Readme.md CHANGED
@@ -1,9 +1,11 @@
1
- # UserAgentParser [![Build Status](https://secure.travis-ci.org/ua-parser/uap-ruby.png?branch=master)](http://travis-ci.org/ua-parser/uap-ruby)
1
+ # UserAgentParser [![Build Status](https://secure.travis-ci.org/ua-parser/uap-ruby.png?branch=master)](http://travis-ci.org/ua-parser/uap-ruby) [![Coverage Status](https://coveralls.io/repos/github/ua-parser/uap-ruby/badge.svg)](https://coveralls.io/github/ua-parser/uap-ruby)
2
2
 
3
3
  UserAgentParser is a simple, comprehensive Ruby gem for parsing user agent strings. It uses [BrowserScope](http://www.browserscope.org/)'s [parsing patterns](https://github.com/ua-parser/uap-core).
4
4
 
5
5
  ## Supported Rubies
6
6
 
7
+ * Ruby 2.4
8
+ * Ruby 2.3
7
9
  * Ruby 2.2
8
10
  * Ruby 2.1
9
11
  * Ruby 2.0
@@ -39,6 +41,26 @@ operating_system = user_agent.os
39
41
  operating_system.to_s
40
42
  => "Windows Vista"
41
43
 
44
+ # Device information can also be determined from some devices
45
+ user_agent = UserAgentParser.parse "Mozilla/5.0 (Linux; Android 7.0; SAMSUNG SM-G930T Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/5.0 Chrome/51.0.2704.106 Mobile Safari/537.36"
46
+ => #<UserAgentParser::UserAgent Samsung Internet 5.0 (Android 7.0) (Samsung SM-G930T)>
47
+ user_agent.device.family
48
+ => "Samsung SM-G930T"
49
+ user_agent.device.brand
50
+ => "Samsung"
51
+ user_agent.device.model
52
+ => "SM-G930T"
53
+
54
+ user_agent = UserAgentParser.parse "Mozilla/5.0 (iPad; CPU OS 10_2_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) GSA/23.1.148956103 Mobile/14D27 Safari/600.1.4"
55
+ => #<UserAgentParser::UserAgent Mobile Safari 10.2.1 (iOS 10.2.1) (iPad)>
56
+ irb(main):026:0> user_agent.device.family
57
+ => "iPad"
58
+ irb(main):027:0> user_agent.device.brand
59
+ => "Apple"
60
+ irb(main):028:0> user_agent.device.model
61
+ => "iPad"
62
+
63
+
42
64
  # The parser database will be loaded and parsed on every call to
43
65
  # UserAgentParser.parse. To avoid this, instantiate your own Parser instance.
44
66
  parser = UserAgentParser::Parser.new
@@ -1,11 +1,13 @@
1
1
  module UserAgentParser
2
2
  class Device
3
- attr_reader :family
3
+ attr_reader :family, :model, :brand
4
4
 
5
5
  alias_method :name, :family
6
6
 
7
- def initialize(family = nil)
7
+ def initialize(family = nil, model = nil, brand = nil)
8
8
  @family = family || 'Other'
9
+ @model = model || @family
10
+ @brand = brand
9
11
  end
10
12
 
11
13
  def to_s
@@ -128,14 +128,26 @@ module UserAgentParser
128
128
 
129
129
  def device_from_pattern_match(pattern, match)
130
130
  match = match.to_a.map(&:to_s)
131
- family = match[1]
131
+ family = model = match[1]
132
+ brand = nil
132
133
 
133
134
  if pattern["device_replacement"]
134
135
  family = pattern["device_replacement"]
135
136
  match.each_with_index { |m,i| family = family.sub("$#{i}", m) }
136
137
  end
138
+ if pattern["model_replacement"]
139
+ model = pattern["model_replacement"]
140
+ match.each_with_index { |m,i| model = model.sub("$#{i}", m) }
141
+ end
142
+ if pattern["brand_replacement"]
143
+ brand = pattern["brand_replacement"]
144
+ match.each_with_index { |m,i| brand = brand.sub("$#{i}", m) }
145
+ brand.strip!
146
+ end
147
+
148
+ model.strip! unless model.nil?
137
149
 
138
- Device.new(family.strip)
150
+ Device.new(family.strip, model, brand)
139
151
  end
140
152
 
141
153
  def version_from_segments(*segments)
@@ -12,6 +12,10 @@ user_agent_parsers:
12
12
  - regex: '(PingdomTMS)/(\d+)\.(\d+)\.(\d+)'
13
13
  family_replacement: 'PingdomBot'
14
14
 
15
+ # New Relic Pinger
16
+ - regex: '(NewRelicPinger)/(\d+)\.(\d+)'
17
+ family_replacement: 'NewRelicPingerBot'
18
+
15
19
  #StatusCake
16
20
  - regex: '(\(StatusCake\))'
17
21
  family_replacement: 'StatusCakeBot'
@@ -311,7 +315,7 @@ user_agent_parsers:
311
315
  # Slack desktop client (needs to be before Apple Mail, Electron, and Chrome as it gets wrongly detected on Mac OS otherwise)
312
316
  - regex: '(Slack_SSB)/(\d+)\.(\d+)\.(\d+)'
313
317
  family_replacement: 'Slack Desktop Client'
314
-
318
+
315
319
  # HipChat provides a version on Mac, but not on Windows.
316
320
  # Needs to be before Chrome on Windows, and AppleMail on Mac.
317
321
  - regex: '(HipChat)/?(\d+)?'
@@ -1991,6 +1995,11 @@ device_parsers:
1991
1995
  device_replacement: 'Gionee $1'
1992
1996
  brand_replacement: 'Gionee'
1993
1997
  model_replacement: '$1'
1998
+ - regex: '\sGIONEE[-\s_](\w*)'
1999
+ regex_flag: 'i'
2000
+ device_replacement: 'Gionee $1'
2001
+ brand_replacement: 'Gionee'
2002
+ model_replacement: '$1'
1994
2003
 
1995
2004
  #########
1996
2005
  # GoClever
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: user_agent_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.2
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Lucas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-18 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2017-09-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: coveralls
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.8.21
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.8.21
13
27
  description: A simple, comprehensive Ruby gem for parsing user agent strings with
14
28
  the help of BrowserScope's UA database
15
29
  email: t@toolmantim.com
@@ -49,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
63
  version: '0'
50
64
  requirements: []
51
65
  rubyforge_project:
52
- rubygems_version: 2.6.10
66
+ rubygems_version: 2.6.12
53
67
  signing_key:
54
68
  specification_version: 4
55
69
  summary: A simple, comprehensive Ruby gem for parsing user agent strings with the