useragent 0.7.0 → 0.8.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: c0120f69b4e121786db5270652b47b8533658243
4
- data.tar.gz: e2cff433dd5079b86067608f059db2a044ff1e48
3
+ metadata.gz: 2658435598c1604bdebca0e0d989073e2e01a788
4
+ data.tar.gz: 7a8ecbe3137b1c26dff955a319955e5ef47e2007
5
5
  SHA512:
6
- metadata.gz: 11de96864692a2eac9e6df71bf87d61ddba15875bc6673513c8f901447bb3e96bd1e5837f3fce4fd5c3264c02c40d0ee010ee3af6d113cf09d276057e94bda5f
7
- data.tar.gz: 1146610d2c06d901ddd4bb51728253e2d18e6c4fe75cf26be0ebebd707c08cf4e161fa56ae436867f8f82f333a359eb3ea06b9d4e92e1ce389cbd1458fb79ef4
6
+ metadata.gz: 191b834bc118d29098f5b22b5c980d74fb8d5b63f41092804a16fe0c987d0bf00981a5db18153e3bc3b4afd220d8524097be4c8bed15206db511838c98df7546
7
+ data.tar.gz: 153c59ccf82db939f2215dd1df088fedf9d557767d2d3085504f3421ae2c1a94b651afa1a468cc9d7e346ed307d45bfd561198b860b0eb285fcaaeda46c78ac6
@@ -1,4 +1,5 @@
1
1
  require 'user_agent/browsers/all'
2
+ require 'user_agent/browsers/chrome'
2
3
  require 'user_agent/browsers/gecko'
3
4
  require 'user_agent/browsers/internet_explorer'
4
5
  require 'user_agent/browsers/opera'
@@ -13,7 +14,7 @@ class UserAgent
13
14
  }.freeze
14
15
 
15
16
  def self.all
16
- [InternetExplorer, Webkit, Opera, Gecko]
17
+ [InternetExplorer, Chrome, Webkit, Opera, Gecko]
17
18
  end
18
19
 
19
20
  def self.extend(array)
@@ -52,16 +52,8 @@ class UserAgent
52
52
  detect_product(method) || super
53
53
  end
54
54
 
55
- def webkit?
56
- false
57
- end
58
-
59
55
  def mobile?
60
- if browser == 'webOS'
61
- true
62
- elsif platform == 'Symbian'
63
- true
64
- elsif detect_product('Mobile') || detect_comment('Mobile')
56
+ if detect_product('Mobile') || detect_comment('Mobile')
65
57
  true
66
58
  elsif os =~ /Android/
67
59
  true
@@ -88,6 +80,8 @@ class UserAgent
88
80
  # list will be rejected.
89
81
  elsif comment = application.comment
90
82
  comment.any? { |c| c =~ /bot/i }
83
+ elsif product = application.product
84
+ product.include?('bot')
91
85
  else
92
86
  false
93
87
  end
@@ -2,11 +2,14 @@ class UserAgent
2
2
  module Browsers
3
3
  module Opera
4
4
  def self.extend?(agent)
5
- agent.application && agent.application.product == "Opera"
5
+ agent.first.product == 'Opera' ||
6
+ (agent.application && agent.application.product == 'Opera')
6
7
  end
7
8
 
8
9
  def version
9
- if product = detect_product('Version')
10
+ if mini?
11
+ application.comment[1][/Opera Mini\/([\d\.]+)/, 1]
12
+ elsif product = detect_product('Version')
10
13
  product.version
11
14
  else
12
15
  super
@@ -35,10 +38,6 @@ class UserAgent
35
38
  end
36
39
  end
37
40
 
38
- def mini?
39
- /Opera Mini/ === application
40
- end
41
-
42
41
  def mobile?
43
42
  mini?
44
43
  end
@@ -62,6 +61,11 @@ class UserAgent
62
61
  application.comment[2]
63
62
  end
64
63
  end
64
+
65
+ private
66
+ def mini?
67
+ /Opera Mini/ === application
68
+ end
65
69
  end
66
70
  end
67
71
  end
@@ -5,16 +5,10 @@ class UserAgent
5
5
  agent.detect { |useragent| useragent.product == 'AppleWebKit' }
6
6
  end
7
7
 
8
- def webkit?
9
- true
10
- end
11
-
12
8
  def browser
13
- if detect_product('Chrome') || detect_product("CriOS")
14
- 'Chrome'
15
- elsif os =~ /Android/
9
+ if os =~ /Android/
16
10
  'Android'
17
- elsif platform == 'webOS' || platform == 'BlackBerry' || platform == 'Symbian'
11
+ elsif platform == 'BlackBerry'
18
12
  platform
19
13
  else
20
14
  'Safari'
@@ -64,12 +58,6 @@ class UserAgent
64
58
  $1.gsub(/_/, '.')
65
59
  elsif product = detect_product('Version')
66
60
  product.version
67
- elsif browser == 'Chrome'
68
- if detect_product("chrome")
69
- chrome.version
70
- elsif detect_product("crios")
71
- crios.version
72
- end
73
61
  else
74
62
  BuildVersions[build.to_s]
75
63
  end
@@ -84,10 +72,6 @@ class UserAgent
84
72
  def platform
85
73
  if application.nil?
86
74
  nil
87
- elsif application.comment[0] =~ /Symbian/
88
- 'Symbian'
89
- elsif application.comment[0] =~ /webOS/
90
- 'webOS'
91
75
  elsif application.comment[0] =~ /Windows/
92
76
  'Windows'
93
77
  elsif application.comment[0] == 'BB10'
@@ -106,11 +90,7 @@ class UserAgent
106
90
  end
107
91
 
108
92
  def os
109
- if platform == 'webOS'
110
- "Palm #{last.product} #{last.version}"
111
- elsif platform == 'Symbian'
112
- application.comment[0]
113
- elsif application
93
+ if application
114
94
  if application.comment[0] =~ /Windows NT/
115
95
  OperatingSystems.normalize_os(application.comment[0])
116
96
  elsif application.comment[2].nil?
@@ -128,8 +108,6 @@ class UserAgent
128
108
  def localization
129
109
  if application.nil?
130
110
  nil
131
- elsif platform == 'webOS'
132
- application.comment[2]
133
111
  else
134
112
  application.comment[3]
135
113
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: useragent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Peek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-18 00:00:00.000000000 Z
11
+ date: 2013-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -59,7 +59,8 @@ files:
59
59
  - LICENSE
60
60
  - README.rdoc
61
61
  homepage: http://github.com/josh/useragent
62
- licenses: []
62
+ licenses:
63
+ - MIT
63
64
  metadata: {}
64
65
  post_install_message:
65
66
  rdoc_options: []