useragent 0.4.16 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +1 -1
- data/README.rdoc +2 -4
- data/lib/user_agent/browsers/all.rb +7 -1
- data/lib/user_agent/browsers/internet_explorer.rb +1 -1
- data/lib/user_agent/browsers/webkit.rb +5 -3
- data/lib/user_agent/operating_systems.rb +13 -1
- metadata +13 -21
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ecc00650c07d846ea38bcb5cd16475b84d51915e
|
4
|
+
data.tar.gz: befbabc6d8c1df3cf374401a79f146a6c99e4528
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ff947472eb8e67b26049dc96b36ac5915131d8d69c4e8aea9f132133c1b1530363dd9835e0affec2e5e34c6c04e398b9655b4a92d8110a7b20fe0c1e37bb5e7a
|
7
|
+
data.tar.gz: e9b0f2fff90b7a38cbeaa05da2dc0e73d30113f8a1ce109457c1c22547325141c0186761eb6a335bfccb2fa43b818004ab0d265b3e99b5d70e51e8b9e0ff523a
|
data/LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -11,15 +11,13 @@ UserAgent is a Ruby library that parses and compares HTTP User Agents.
|
|
11
11
|
==== Reporting
|
12
12
|
|
13
13
|
string = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5'
|
14
|
-
user_agent = UserAgent.parse(string)
|
14
|
+
user_agent = UserAgent.parse(string)
|
15
15
|
user_agent.browser
|
16
16
|
# => 'Chrome'
|
17
17
|
user_agent.version
|
18
18
|
# => '19.0.1084.56'
|
19
19
|
user_agent.platform
|
20
20
|
# => 'Macintosh'
|
21
|
-
user_agent.mobile?
|
22
|
-
# => false
|
23
21
|
|
24
22
|
==== Comparison
|
25
23
|
|
@@ -34,4 +32,4 @@ UserAgent is a Ruby library that parses and compares HTTP User Agents.
|
|
34
32
|
SupportedBrowsers.detect { |browser| user_agent >= browser }
|
35
33
|
|
36
34
|
|
37
|
-
Copyright (c)
|
35
|
+
Copyright (c) 2013 Joshua Peek, released under the MIT license
|
@@ -61,7 +61,9 @@ class UserAgent
|
|
61
61
|
true
|
62
62
|
elsif platform == 'Symbian'
|
63
63
|
true
|
64
|
-
elsif detect_product('Mobile')
|
64
|
+
elsif detect_product('Mobile') || detect_comment('Mobile')
|
65
|
+
true
|
66
|
+
elsif os =~ /Android/
|
65
67
|
true
|
66
68
|
elsif application && application.comment &&
|
67
69
|
application.comment.detect { |k, v| k =~ /^IEMobile/ }
|
@@ -95,6 +97,10 @@ class UserAgent
|
|
95
97
|
def detect_product(product)
|
96
98
|
detect { |useragent| useragent.product.to_s.downcase == product.to_s.downcase }
|
97
99
|
end
|
100
|
+
|
101
|
+
def detect_comment(comment)
|
102
|
+
detect { |useragent| useragent.comment && useragent.comment.include?(comment) }
|
103
|
+
end
|
98
104
|
end
|
99
105
|
end
|
100
106
|
end
|
@@ -10,10 +10,10 @@ class UserAgent
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def browser
|
13
|
-
if
|
14
|
-
'Android'
|
15
|
-
elsif detect_product('Chrome')
|
13
|
+
if detect_product('Chrome')
|
16
14
|
'Chrome'
|
15
|
+
elsif os =~ /Android/
|
16
|
+
'Android'
|
17
17
|
elsif platform == 'webOS' || platform == 'BlackBerry' || platform == 'Symbian'
|
18
18
|
platform
|
19
19
|
else
|
@@ -111,6 +111,8 @@ class UserAgent
|
|
111
111
|
OperatingSystems.normalize_os(application.comment[0])
|
112
112
|
elsif application.comment[2].nil?
|
113
113
|
OperatingSystems.normalize_os(application.comment[1])
|
114
|
+
elsif application.comment[1] =~ /Android/
|
115
|
+
OperatingSystems.normalize_os(application.comment[1])
|
114
116
|
else
|
115
117
|
OperatingSystems.normalize_os(application.comment[2])
|
116
118
|
end
|
@@ -15,7 +15,19 @@ class UserAgent
|
|
15
15
|
}.freeze
|
16
16
|
|
17
17
|
def self.normalize_os(os)
|
18
|
-
Windows[os] || os
|
18
|
+
Windows[os] || normalize_mac_os_x(os) || os
|
19
19
|
end
|
20
|
+
|
21
|
+
private
|
22
|
+
def self.normalize_mac_os_x(os)
|
23
|
+
if os =~ /(?:Intel|PPC) Mac OS X\s*([0-9_\.]+)?/
|
24
|
+
if $1.nil?
|
25
|
+
"OS X"
|
26
|
+
else
|
27
|
+
version = $1.gsub('_', '.')
|
28
|
+
"OS X #{version}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
20
32
|
end
|
21
33
|
end
|
metadata
CHANGED
@@ -1,51 +1,45 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: useragent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.5.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Joshua Peek
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-03-23 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rake
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rspec
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
|
-
description:
|
47
|
-
|
48
|
-
'
|
41
|
+
description: |2
|
42
|
+
HTTP User Agent parser
|
49
43
|
email: josh@joshpeek.com
|
50
44
|
executables: []
|
51
45
|
extensions: []
|
@@ -66,27 +60,25 @@ files:
|
|
66
60
|
- README.rdoc
|
67
61
|
homepage: http://github.com/josh/useragent
|
68
62
|
licenses: []
|
63
|
+
metadata: {}
|
69
64
|
post_install_message:
|
70
65
|
rdoc_options: []
|
71
66
|
require_paths:
|
72
67
|
- lib
|
73
68
|
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
-
none: false
|
75
69
|
requirements:
|
76
|
-
- -
|
70
|
+
- - '>='
|
77
71
|
- !ruby/object:Gem::Version
|
78
72
|
version: '0'
|
79
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
-
none: false
|
81
74
|
requirements:
|
82
|
-
- -
|
75
|
+
- - '>='
|
83
76
|
- !ruby/object:Gem::Version
|
84
77
|
version: '0'
|
85
78
|
requirements: []
|
86
79
|
rubyforge_project:
|
87
|
-
rubygems_version:
|
80
|
+
rubygems_version: 2.0.0
|
88
81
|
signing_key:
|
89
|
-
specification_version:
|
82
|
+
specification_version: 4
|
90
83
|
summary: HTTP User Agent parser
|
91
84
|
test_files: []
|
92
|
-
has_rdoc:
|