useragent 0.16.3 → 0.16.4

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: c20bcc2861b91b9daa438d2a1c436dc5b8904623
4
- data.tar.gz: 05f1418f81ef79ea1388800f2f2b10d6e365035b
3
+ metadata.gz: e43d6316204c15aaad84fa02b020866075b39fa8
4
+ data.tar.gz: b716e6cfe14f3be5bbdfbaa3c9c750203cec9d86
5
5
  SHA512:
6
- metadata.gz: 1b57837939d11ece3dc65209dca3d667390737a44f700af5d2533c2127731a5ed4a18dd7243a491a67a95bf38ddbf2a38cb98dad62e508a17d2bd4c0bc625298
7
- data.tar.gz: 0ea1c78533a067e7833bdd57d3e652b12a634b61aea529d1ab3cec8a1c0c5c08d69d82a76cd1c22f5830613e61cc1e02e16f74f1ee8a5090396caff6cde5fbee
6
+ metadata.gz: 1ba86b3534c32e44b16c1b894f40b4be839e629fa81cd73dec2055f3ce95991fb0cb02a7055591eb3f6a7781713fb4122eb04133f43239672e73a8b1a81a1e01
7
+ data.tar.gz: b708812c912e47f4ae9bfedaf385bdd59dc42011a100a33868514bc68399713a561843d195472c6a253e1e599b507dac78684f4b83a6d66380bae5da39859a10
@@ -11,13 +11,13 @@ class UserAgent
11
11
  end
12
12
 
13
13
  def application
14
- self.reject { |agent| agent.comment.nil? || agent.comment.empty? }.first
14
+ self.reject { |agent| agent.comment.nil? || agent.comment.empty? }.first
15
15
  end
16
16
 
17
17
  def platform
18
- if application.nil?
19
- nil
20
- elsif application.comment[0] =~ /Windows/
18
+ return unless application
19
+
20
+ if application.comment[0] =~ /Windows/
21
21
  'Windows'
22
22
  else
23
23
  application.comment[0]
@@ -29,27 +29,23 @@ class UserAgent
29
29
  end
30
30
 
31
31
  def os
32
- if application
33
- if application.comment[0] =~ /Windows NT/
34
- OperatingSystems.normalize_os(application.comment[0])
35
- elsif application.comment[2].nil?
36
- OperatingSystems.normalize_os(application.comment[1])
37
- elsif application.comment[1] =~ /Android/
38
- OperatingSystems.normalize_os(application.comment[1])
39
- else
40
- OperatingSystems.normalize_os(application.comment[2])
41
- end
32
+ return unless application
33
+
34
+ if application.comment[0] =~ /Windows NT/
35
+ OperatingSystems.normalize_os(application.comment[0])
36
+ elsif application.comment[2].nil?
37
+ OperatingSystems.normalize_os(application.comment[1])
38
+ elsif application.comment[1] =~ /Android/
39
+ OperatingSystems.normalize_os(application.comment[1])
42
40
  else
43
- nil
41
+ OperatingSystems.normalize_os(application.comment[2])
44
42
  end
45
43
  end
46
44
 
47
45
  def localization
48
- if application.nil?
49
- nil
50
- else
51
- application.comment[3]
52
- end
46
+ return unless application
47
+
48
+ application.comment[3]
53
49
  end
54
50
  end
55
51
  end
@@ -88,7 +88,7 @@ class UserAgent
88
88
  end
89
89
 
90
90
  def to_h
91
- return nil unless application
91
+ return unless application
92
92
 
93
93
  hash = {
94
94
  :browser => browser,
@@ -31,9 +31,9 @@ class UserAgent
31
31
  end
32
32
 
33
33
  def platform
34
- if application.nil?
35
- nil
36
- elsif application.comment[0] =~ /Windows/
34
+ return unless application
35
+
36
+ if application.comment[0] =~ /Windows/
37
37
  'Windows'
38
38
  elsif application.comment.any? { |c| c =~ /CrOS/ }
39
39
  'ChromeOS'
@@ -49,27 +49,23 @@ class UserAgent
49
49
  end
50
50
 
51
51
  def os
52
- if application
53
- if application.comment[0] =~ /Windows NT/
54
- OperatingSystems.normalize_os(application.comment[0])
55
- elsif application.comment[2].nil?
56
- OperatingSystems.normalize_os(application.comment[1])
57
- elsif application.comment[1] =~ /Android/
58
- OperatingSystems.normalize_os(application.comment[1])
59
- else
60
- OperatingSystems.normalize_os(application.comment[2])
61
- end
52
+ return unless application
53
+
54
+ if application.comment[0] =~ /Windows NT/
55
+ OperatingSystems.normalize_os(application.comment[0])
56
+ elsif application.comment[2].nil?
57
+ OperatingSystems.normalize_os(application.comment[1])
58
+ elsif application.comment[1] =~ /Android/
59
+ OperatingSystems.normalize_os(application.comment[1])
62
60
  else
63
- nil
61
+ OperatingSystems.normalize_os(application.comment[2])
64
62
  end
65
63
  end
66
64
 
67
65
  def localization
68
- if application.nil?
69
- nil
70
- else
71
- application.comment[3]
72
- end
66
+ return unless application
67
+
68
+ application.comment[3]
73
69
  end
74
70
  end
75
71
  end
@@ -2,6 +2,7 @@ class UserAgent
2
2
  module Browsers
3
3
  class InternetExplorer < Base
4
4
  TRIDENT_ENGINES = {
5
+ "Trident/8.0" => "11.0",
5
6
  "Trident/7.0" => "11.0",
6
7
  "Trident/6.0" => "10.0",
7
8
  "Trident/5.0" => "9.0",
@@ -30,8 +30,8 @@ class UserAgent
30
30
 
31
31
  # @return [nil, Version] The WebKit version in use if we have it
32
32
  def build
33
- webkit ? super : nil
34
- end
33
+ super if webkit
34
+ end
35
35
 
36
36
  # Parses the operating system in use.
37
37
  #
@@ -66,10 +66,8 @@ class UserAgent
66
66
  full_os = application.comment[1]
67
67
 
68
68
  full_os = "#{full_os})" if full_os =~ /\(Build [0-9][0-9][0-9][0-9]\z/ # The regex chops the ) off :(
69
-
69
+
70
70
  full_os
71
- else
72
- nil
73
71
  end
74
72
  end
75
73
  end
@@ -15,11 +15,7 @@ class UserAgent
15
15
 
16
16
  # @return [nil, Version] If the product is NSPlayer, we don't have a version
17
17
  def version
18
- if detect_product("NSPlayer")
19
- nil
20
- else
21
- super
22
- end
18
+ super unless detect_product("NSPlayer")
23
19
  end
24
20
 
25
21
  # @return [nil] Lavf doesn't return us anything here
@@ -24,9 +24,9 @@ class UserAgent
24
24
  end
25
25
 
26
26
  def platform
27
- if application.comment.nil?
28
- nil
29
- elsif application.comment[0] =~ /Windows/
27
+ return unless application.comment
28
+
29
+ if application.comment[0] =~ /Windows/
30
30
  "Windows"
31
31
  else
32
32
  application.comment[0]
@@ -36,7 +36,7 @@ class UserAgent
36
36
  def security
37
37
  if application.comment.nil?
38
38
  :strong
39
- elsif platform == "Macintosh"
39
+ elsif macintosh?
40
40
  Security[application.comment[2]]
41
41
  elsif mini?
42
42
  Security[application.comment[-2]]
@@ -50,9 +50,9 @@ class UserAgent
50
50
  end
51
51
 
52
52
  def os
53
- if application.comment.nil?
54
- nil
55
- elsif application.comment[0] =~ /Windows/
53
+ return unless application.comment
54
+
55
+ if application.comment[0] =~ /Windows/
56
56
  OperatingSystems.normalize_os(application.comment[0])
57
57
  else
58
58
  application.comment[1]
@@ -60,9 +60,9 @@ class UserAgent
60
60
  end
61
61
 
62
62
  def localization
63
- if application.comment.nil?
64
- nil
65
- elsif platform == "Macintosh"
63
+ return unless application.comment
64
+
65
+ if macintosh?
66
66
  application.comment[3]
67
67
  else
68
68
  application.comment[2]
@@ -73,6 +73,10 @@ class UserAgent
73
73
  def mini?
74
74
  /Opera Mini/ === application
75
75
  end
76
+
77
+ def macintosh?
78
+ platform == 'Macintosh'
79
+ end
76
80
  end
77
81
  end
78
82
  end
@@ -66,13 +66,13 @@ class UserAgent
66
66
  end
67
67
 
68
68
  def application
69
- self.reject { |agent| agent.comment.nil? || agent.comment.empty? }.first
69
+ self.reject { |agent| agent.comment.nil? || agent.comment.empty? }.first
70
70
  end
71
71
 
72
72
  def platform
73
- if application.nil?
74
- nil
75
- elsif application.comment[0] =~ /Windows/
73
+ return unless application
74
+
75
+ if application.comment[0] =~ /Windows/
76
76
  'Windows'
77
77
  elsif application.comment[0] == 'BB10'
78
78
  'BlackBerry'
@@ -92,29 +92,25 @@ class UserAgent
92
92
  end
93
93
 
94
94
  def os
95
- if application
96
- if application.comment[0] =~ /Windows NT/
97
- OperatingSystems.normalize_os(application.comment[0])
98
- elsif application.comment[2].nil?
99
- OperatingSystems.normalize_os(application.comment[1])
100
- elsif application.comment[1] =~ /Android/
101
- OperatingSystems.normalize_os(application.comment[1])
102
- elsif (os_string = application.comment.detect { |c| c =~ OperatingSystems::IOS_VERSION_REGEX })
103
- OperatingSystems.normalize_os(os_string)
104
- else
105
- OperatingSystems.normalize_os(application.comment[2])
106
- end
95
+ return unless application
96
+
97
+ if application.comment[0] =~ /Windows NT/
98
+ OperatingSystems.normalize_os(application.comment[0])
99
+ elsif application.comment[2].nil?
100
+ OperatingSystems.normalize_os(application.comment[1])
101
+ elsif application.comment[1] =~ /Android/
102
+ OperatingSystems.normalize_os(application.comment[1])
103
+ elsif (os_string = application.comment.detect { |c| c =~ OperatingSystems::IOS_VERSION_REGEX })
104
+ OperatingSystems.normalize_os(os_string)
107
105
  else
108
- nil
106
+ OperatingSystems.normalize_os(application.comment[2])
109
107
  end
110
108
  end
111
109
 
112
110
  def localization
113
- if application.nil?
114
- nil
115
- else
116
- application.comment[3]
117
- end
111
+ return unless application
112
+
113
+ application.comment[3]
118
114
  end
119
115
  end
120
116
  end
@@ -8,7 +8,7 @@ class UserAgent
8
8
  class WindowsMediaPlayer < Base
9
9
  def self.extend?(agent)
10
10
  agent.detect do |useragent|
11
- (useragent.product == "NSPlayer" || useragent.product == "Windows-Media-Player" || useragent.product == "WMFSDK") &&
11
+ %w(NSPlayer Windows-Media-Player WMFSDK).include?(useragent.product) &&
12
12
  agent.version != "4.1.0.3856" && # 4.1.0.3856 is libavformat
13
13
  agent.version != "7.10.0.3059" && # used by VLC for mmsh support
14
14
  agent.version != "7.0.0.1956" # used by VLC for mmstu support
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: useragent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.3
4
+ version: 0.16.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Peek
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-12-15 00:00:00.000000000 Z
12
+ date: 2016-02-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake