useragent_parser 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +2 -6
- data/config/regexes.yaml +4 -1
- data/lib/useragent_parser/version.rb +1 -1
- data/spec/fixtures/test_user_agent_parser.yaml +6 -0
- data/spec/fixtures/test_user_agent_parser_email.yaml +6 -0
- data/spec/parsers/device_parser_spec.rb +3 -3
- data/spec/parsers/os_parser_spec.rb +10 -10
- data/spec/parsers/referrer_parser_spec.rb +1 -1
- data/spec/parsers/useragent_parser_spec.rb +16 -16
- data/spec/spec_helper.rb +0 -1
- data/spec/user_agent_spec.rb +78 -78
- data/spec/useragent_parser_spec.rb +57 -12
- data/useragent_parser.gemspec +2 -3
- metadata +17 -39
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 396b4d1db6995c91e979b4d8c1ee698e9f9e0eff
|
4
|
+
data.tar.gz: 032822542166c4b9508a4cef74fca700ceb10f73
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a14213c0377e981f1fd5c4ff5c0613436e73de41c37f8e7a7aec5df43c4e9e3d1e76b2009a07b658f15c6e13e07b8bf52564a8cbf4c783a2efbb222116852ad3
|
7
|
+
data.tar.gz: 1df6b0f84c4722741c8db38305975c994a5cfc0984a0b61e14260aff2db098c338bbed2e01dd6128d20f5603ca1968dec91cd4e142bb0d93b17385477b5c4ec4
|
data/.travis.yml
CHANGED
data/config/regexes.yaml
CHANGED
@@ -192,7 +192,7 @@ user_agent_parsers:
|
|
192
192
|
#### MAIN CASES - this catches > 50% of all browsers ####
|
193
193
|
|
194
194
|
# Browser/major_version.minor_version.beta_version
|
195
|
-
- regex: '(AdobeAIR|Chromium|FireWeb|Jasmine|ANTGalio|Midori|Fresco|Lobo|PaleMoon|Maxthon|Lynx|OmniWeb|Dillo|Camino|Demeter|Fluid|Fennec|Shiira|Sunrise|Chrome|Flock|Netscape|Lunascape|WebPilot|Vodafone|NetFront|Netfront|Konqueror|SeaMonkey|Kazehakase|Vienna|Iceape|Iceweasel|IceWeasel|Iron|K-Meleon|Sleipnir|Galeon|GranParadiso|Opera Mini|iCab|NetNewsWire|Thunderbird|ThunderBrowse|Iris|UP\.Browser|Bunjaloo|Google Earth|Raven for Mac)/(\d+)\.(\d+)\.(\d+)'
|
195
|
+
- regex: '(AdobeAIR|Chromium|FireWeb|Jasmine|ANTGalio|Midori|Fresco|Lobo|PaleMoon|Maxthon|Lynx|OmniWeb|Dillo|Camino|Demeter|Fluid|Fennec|Shiira|Sunrise|Chrome|Flock|Netscape|Lunascape|WebPilot|Vodafone|NetFront|Netfront|Konqueror|SeaMonkey|Kazehakase|Vienna|Iceape|Iceweasel|IceWeasel|Iron|K-Meleon|Sleipnir|Galeon|GranParadiso|Opera Mini|iCab|NetNewsWire|Thunderbird|Postbox|ThunderBrowse|Iris|UP\.Browser|Bunjaloo|Google Earth|Raven for Mac)/(\d+)\.(\d+)\.(\d+)'
|
196
196
|
|
197
197
|
# Browser/major_version.minor_version
|
198
198
|
- regex: '(Bolt|Jasmine|IceCat|Skyfire|Midori|Maxthon|Lynx|Arora|IBrowse|Dillo|Camino|Shiira|Fennec|Phoenix|Chrome|Flock|Netscape|Lunascape|Epiphany|WebPilot|Opera Mini|Opera|Vodafone|NetFront|Netfront|Konqueror|Googlebot|SeaMonkey|Kazehakase|Vienna|Iceape|Iceweasel|IceWeasel|Iron|K-Meleon|Sleipnir|Galeon|GranParadiso|iCab|NetNewsWire|Space Bison|Stainless|Orca|Dolfin|BOLT|Minimo|Tizen Browser|Polaris|Abrowser|Thunderbird)/(\d+)\.(\d+)'
|
@@ -355,6 +355,9 @@ user_agent_parsers:
|
|
355
355
|
- regex: '(MSIE) (\d+)\.(\d+)'
|
356
356
|
family_replacement: 'IE'
|
357
357
|
|
358
|
+
- regex: '(Trident/7.0). rv:(\d+).(\d+)'
|
359
|
+
family_replacement: 'IE'
|
360
|
+
|
358
361
|
- regex: '(Nintendo 3DS).* Version/(\d+)\.(\d+)(?:\.(\w+))'
|
359
362
|
|
360
363
|
# Generic AppleWebKit detection
|
@@ -1,5 +1,11 @@
|
|
1
1
|
test_cases:
|
2
2
|
|
3
|
+
- user_agent_string: 'Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko'
|
4
|
+
family: 'IE'
|
5
|
+
major: '11'
|
6
|
+
minor: '0'
|
7
|
+
patch:
|
8
|
+
|
3
9
|
- user_agent_string: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/537.8+ (KHTML, like Gecko) Version/6.0 Safari/536.25'
|
4
10
|
family: 'WebKit Nightly'
|
5
11
|
major: '537'
|
@@ -2193,3 +2193,9 @@ test_cases:
|
|
2193
2193
|
major: '15'
|
2194
2194
|
minor:
|
2195
2195
|
patch:
|
2196
|
+
|
2197
|
+
- user_agent_string: 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.8) Gecko/20100317 Postbox/1.1.3'
|
2198
|
+
family: 'Postbox'
|
2199
|
+
major: '1'
|
2200
|
+
minor: '1'
|
2201
|
+
patch: '3'
|
@@ -10,9 +10,9 @@ describe UseragentParser::DeviceParser do
|
|
10
10
|
js_ua = [ js_ua['js_user_agent_string'], js_ua['js_user_agent_family'], js_ua['js_user_agent_v1'], js_ua['js_user_agent_v2'], js_ua['js_user_agent_v3'] ]
|
11
11
|
end
|
12
12
|
result = UseragentParser.parse_device(testcase['user_agent_string'], *js_ua)
|
13
|
-
result['family'].
|
14
|
-
result['is_mobile'].
|
15
|
-
result['is_spider'].
|
13
|
+
expect(result['family']).to eq(testcase['family'])
|
14
|
+
expect(result['is_mobile']).to eq(testcase['is_mobile'])
|
15
|
+
expect(result['is_spider']).to eq(testcase['is_spider'])
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -10,11 +10,11 @@ describe UseragentParser::OSParser do
|
|
10
10
|
js_ua = [ js_ua['js_user_agent_string'], js_ua['js_user_agent_family'], js_ua['js_user_agent_v1'], js_ua['js_user_agent_v2'], js_ua['js_user_agent_v3'] ]
|
11
11
|
end
|
12
12
|
result = UseragentParser.parse_os(testcase['user_agent_string'], *js_ua)
|
13
|
-
result['family'].
|
14
|
-
result['major'].
|
15
|
-
result['minor'].
|
16
|
-
result['patch'].
|
17
|
-
result['patch_minor'].
|
13
|
+
expect(result['family']).to eq(testcase['family'])
|
14
|
+
expect(result['major']).to eq(testcase['major'])
|
15
|
+
expect(result['minor']).to eq(testcase['minor'])
|
16
|
+
expect(result['patch']).to eq(testcase['patch'])
|
17
|
+
expect(result['patch_minor']).to eq(testcase['patch_minor'])
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -25,11 +25,11 @@ describe UseragentParser::OSParser do
|
|
25
25
|
js_ua = [ js_ua['js_user_agent_string'], js_ua['js_user_agent_family'], js_ua['js_user_agent_v1'], js_ua['js_user_agent_v2'], js_ua['js_user_agent_v3'] ]
|
26
26
|
end
|
27
27
|
result = UseragentParser.parse_os(testcase['user_agent_string'], *js_ua)
|
28
|
-
result['family'].
|
29
|
-
result['major'].
|
30
|
-
result['minor'].
|
31
|
-
result['patch'].
|
32
|
-
result['patch_minor'].
|
28
|
+
expect(result['family']).to eq(testcase['family'])
|
29
|
+
expect(result['major']).to eq(testcase['major'])
|
30
|
+
expect(result['minor']).to eq(testcase['minor'])
|
31
|
+
expect(result['patch']).to eq(testcase['patch'])
|
32
|
+
expect(result['patch_minor']).to eq(testcase['patch_minor'])
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -6,7 +6,7 @@ describe UseragentParser::ReferrerParser do
|
|
6
6
|
YAML.load_file(File.expand_path(File.dirname(__FILE__)) + "/../fixtures/test_referrers.yaml")['test_cases'].each do |testcase|
|
7
7
|
it "should correctly parse the referrer string '#{testcase['referrer_string']}'" do
|
8
8
|
result = UseragentParser.parse_referrer(testcase['referrer_string'])
|
9
|
-
result['family'].
|
9
|
+
expect(result['family']).to eq(testcase['family'])
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -10,10 +10,10 @@ describe UseragentParser::UserAgentParser do
|
|
10
10
|
js_ua = [ js_ua['js_user_agent_string'], js_ua['js_user_agent_family'], js_ua['js_user_agent_v1'], js_ua['js_user_agent_v2'], js_ua['js_user_agent_v3'] ]
|
11
11
|
end
|
12
12
|
result = UseragentParser.parse_user_agent(testcase['user_agent_string'], *js_ua)
|
13
|
-
result['family'].
|
14
|
-
result['major'].
|
15
|
-
result['minor'].
|
16
|
-
result['patch'].
|
13
|
+
expect(result['family']).to eq(testcase['family'])
|
14
|
+
expect(result['major']).to eq(testcase['major'])
|
15
|
+
expect(result['minor']).to eq(testcase['minor'])
|
16
|
+
expect(result['patch']).to eq(testcase['patch'])
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -24,10 +24,10 @@ describe UseragentParser::UserAgentParser do
|
|
24
24
|
js_ua = [ js_ua['js_user_agent_string'], js_ua['js_user_agent_family'], js_ua['js_user_agent_v1'], js_ua['js_user_agent_v2'], js_ua['js_user_agent_v3'] ]
|
25
25
|
end
|
26
26
|
result = UseragentParser.parse_user_agent(testcase['user_agent_string'], *js_ua)
|
27
|
-
result['family'].
|
28
|
-
result['major'].
|
29
|
-
result['minor'].
|
30
|
-
result['patch'].
|
27
|
+
expect(result['family']).to eq(testcase['family'])
|
28
|
+
expect(result['major']).to eq(testcase['major'])
|
29
|
+
expect(result['minor']).to eq(testcase['minor'])
|
30
|
+
expect(result['patch']).to eq(testcase['patch'])
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -38,10 +38,10 @@ describe UseragentParser::UserAgentParser do
|
|
38
38
|
js_ua = eval(testcase['js_ua'].gsub("': '", "' => '")).values
|
39
39
|
end
|
40
40
|
result = UseragentParser.parse_user_agent(testcase['user_agent_string'], *js_ua)
|
41
|
-
result['family'].
|
42
|
-
result['major'].
|
43
|
-
result['minor'].
|
44
|
-
result['patch'].
|
41
|
+
expect(result['family']).to eq(testcase['family'])
|
42
|
+
expect(result['major']).to eq(testcase['major'])
|
43
|
+
expect(result['minor']).to eq(testcase['minor'])
|
44
|
+
expect(result['patch']).to eq(testcase['patch'])
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -52,10 +52,10 @@ describe UseragentParser::UserAgentParser do
|
|
52
52
|
js_ua = eval(testcase['js_ua'].gsub("': '", "' => '")).values
|
53
53
|
end
|
54
54
|
result = UseragentParser.parse_user_agent(testcase['user_agent_string'], *js_ua)
|
55
|
-
result['family'].
|
56
|
-
result['major'].
|
57
|
-
result['minor'].
|
58
|
-
result['patch'].
|
55
|
+
expect(result['family']).to eq(testcase['family'])
|
56
|
+
expect(result['major']).to eq(testcase['major'])
|
57
|
+
expect(result['minor']).to eq(testcase['minor'])
|
58
|
+
expect(result['patch']).to eq(testcase['patch'])
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/user_agent_spec.rb
CHANGED
@@ -5,99 +5,99 @@ require 'spec_helper'
|
|
5
5
|
describe UseragentParser::UserAgent do
|
6
6
|
describe "for browser details" do
|
7
7
|
it "should report the browser family" do
|
8
|
-
UseragentParser::UserAgent.new({ 'user_agent' => { 'family' => 'Chrome', 'major' => '14', 'minor' => '0', 'patch' => '835' } }).browser_family.
|
8
|
+
expect(UseragentParser::UserAgent.new({ 'user_agent' => { 'family' => 'Chrome', 'major' => '14', 'minor' => '0', 'patch' => '835' } }).browser_family).to eq('Chrome')
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should report the browser major version" do
|
12
|
-
UseragentParser::UserAgent.new({ 'user_agent' => { 'family' => 'Chrome', 'major' => '14', 'minor' => '0', 'patch' => '835' } }).browser_major_version.
|
12
|
+
expect(UseragentParser::UserAgent.new({ 'user_agent' => { 'family' => 'Chrome', 'major' => '14', 'minor' => '0', 'patch' => '835' } }).browser_major_version).to eq('14')
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should report the browser minor version" do
|
16
|
-
UseragentParser::UserAgent.new({ 'user_agent' => { 'family' => 'Chrome', 'major' => '14', 'minor' => '0', 'patch' => '835' } }).browser_minor_version.
|
16
|
+
expect(UseragentParser::UserAgent.new({ 'user_agent' => { 'family' => 'Chrome', 'major' => '14', 'minor' => '0', 'patch' => '835' } }).browser_minor_version).to eq('0')
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should report the browser patch version" do
|
20
|
-
UseragentParser::UserAgent.new({ 'user_agent' => { 'family' => 'Chrome', 'major' => '14', 'minor' => '0', 'patch' => '835' } }).browser_patch_version.
|
20
|
+
expect(UseragentParser::UserAgent.new({ 'user_agent' => { 'family' => 'Chrome', 'major' => '14', 'minor' => '0', 'patch' => '835' } }).browser_patch_version).to eq('835')
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should report the browser version" do
|
24
|
-
UseragentParser::UserAgent.new({ 'user_agent' => { 'family' => 'Chrome', 'major' => '14', 'minor' => '0', 'patch' => '835' } }).browser_version.
|
24
|
+
expect(UseragentParser::UserAgent.new({ 'user_agent' => { 'family' => 'Chrome', 'major' => '14', 'minor' => '0', 'patch' => '835' } }).browser_version).to eq('14.0.835')
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should report the browser version without patch level" do
|
28
|
-
UseragentParser::UserAgent.new({ 'user_agent' => { 'family' => 'Firefox', 'major' => '5', 'minor' => '0' } }).browser_version.
|
28
|
+
expect(UseragentParser::UserAgent.new({ 'user_agent' => { 'family' => 'Firefox', 'major' => '5', 'minor' => '0' } }).browser_version).to eq('5.0')
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should report the browser version without minor version" do
|
32
|
-
UseragentParser::UserAgent.new({ 'user_agent' => { 'family' => 'Firefox', 'major' => '5' } }).browser_version.
|
32
|
+
expect(UseragentParser::UserAgent.new({ 'user_agent' => { 'family' => 'Firefox', 'major' => '5' } }).browser_version).to eq('5')
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should report the browser family without version" do
|
36
|
-
UseragentParser::UserAgent.new({ 'user_agent' => { 'family' => 'Opera' } }).browser_version.
|
36
|
+
expect(UseragentParser::UserAgent.new({ 'user_agent' => { 'family' => 'Opera' } }).browser_version).to eq('')
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
describe "for device details" do
|
41
41
|
it "should report mobile classification" do
|
42
|
-
UseragentParser::UserAgent.new({ 'device' => { 'family' => nil, 'is_mobile' => false, 'is_spider' => false } }).is_mobile
|
43
|
-
UseragentParser::UserAgent.new({ 'device' => { 'family' => nil, 'is_mobile' => true, 'is_spider' => false } }).is_mobile
|
42
|
+
expect(UseragentParser::UserAgent.new({ 'device' => { 'family' => nil, 'is_mobile' => false, 'is_spider' => false } }).is_mobile?).to be_falsey
|
43
|
+
expect(UseragentParser::UserAgent.new({ 'device' => { 'family' => nil, 'is_mobile' => true, 'is_spider' => false } }).is_mobile?).to be_truthy
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should report spider classification" do
|
47
|
-
UseragentParser::UserAgent.new({ 'device' => { 'family' => nil, 'is_mobile' => false, 'is_spider' => false } }).is_spider
|
48
|
-
UseragentParser::UserAgent.new({ 'device' => { 'family' => nil, 'is_mobile' => false, 'is_spider' => true } }).is_spider
|
47
|
+
expect(UseragentParser::UserAgent.new({ 'device' => { 'family' => nil, 'is_mobile' => false, 'is_spider' => false } }).is_spider?).to be_falsey
|
48
|
+
expect(UseragentParser::UserAgent.new({ 'device' => { 'family' => nil, 'is_mobile' => false, 'is_spider' => true } }).is_spider?).to be_truthy
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should report device platform" do
|
52
|
-
UseragentParser::UserAgent.new({ 'device' => { 'family' => 'iPad', 'is_mobile' => true, 'is_spider' => false } }).device.
|
53
|
-
UseragentParser::UserAgent.new({ 'device' => { 'family' => 'iPod', 'is_mobile' => true, 'is_spider' => false } }).device.
|
54
|
-
UseragentParser::UserAgent.new({ 'device' => { 'family' => 'iPhone', 'is_mobile' => true, 'is_spider' => false } }).device.
|
55
|
-
UseragentParser::UserAgent.new({ 'device' => { 'family' => 'GT-P7510', 'is_mobile' => true, 'is_spider' => false } }).device.
|
56
|
-
UseragentParser::UserAgent.new({ 'device' => { 'family' => 'Blackberry Playbook', 'is_mobile' => true, 'is_spider' => false } }).device.
|
57
|
-
UseragentParser::UserAgent.new({ 'device' => { 'family' => 'Spider', 'is_mobile' => false, 'is_spider' => true } }).device.
|
52
|
+
expect(UseragentParser::UserAgent.new({ 'device' => { 'family' => 'iPad', 'is_mobile' => true, 'is_spider' => false } }).device).to eq("iPad")
|
53
|
+
expect(UseragentParser::UserAgent.new({ 'device' => { 'family' => 'iPod', 'is_mobile' => true, 'is_spider' => false } }).device).to eq("iPod")
|
54
|
+
expect(UseragentParser::UserAgent.new({ 'device' => { 'family' => 'iPhone', 'is_mobile' => true, 'is_spider' => false } }).device).to eq("iPhone")
|
55
|
+
expect(UseragentParser::UserAgent.new({ 'device' => { 'family' => 'GT-P7510', 'is_mobile' => true, 'is_spider' => false } }).device).to eq("GT-P7510")
|
56
|
+
expect(UseragentParser::UserAgent.new({ 'device' => { 'family' => 'Blackberry Playbook', 'is_mobile' => true, 'is_spider' => false } }).device).to eq("Blackberry Playbook")
|
57
|
+
expect(UseragentParser::UserAgent.new({ 'device' => { 'family' => 'Spider', 'is_mobile' => false, 'is_spider' => true } }).device).to eq("Spider")
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
61
|
describe "for email client" do
|
62
62
|
it "should detect Mozilla Thunderbird" do
|
63
|
-
UseragentParser.parse_with_referrer('Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; de; rv:1.9.2.15) Gecko/20110303 Lightning/1.0b2 Thunderbird/3.1.9').email.
|
63
|
+
expect(UseragentParser.parse_with_referrer('Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; de; rv:1.9.2.15) Gecko/20110303 Lightning/1.0b2 Thunderbird/3.1.9').email).to eq('Thunderbird')
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should detect Windows Live Mail" do
|
67
|
-
UseragentParser.parse_with_referrer('Outlook-Express/7.0 (MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30618; TmstmpExt)').email.
|
67
|
+
expect(UseragentParser.parse_with_referrer('Outlook-Express/7.0 (MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30618; TmstmpExt)').email).to eq('Windows Live Mail')
|
68
68
|
end
|
69
69
|
|
70
70
|
it "should detect Eudora" do
|
71
|
-
UseragentParser.parse_with_referrer('Eudora/6.2.3b9 (MacOS)').email.
|
71
|
+
expect(UseragentParser.parse_with_referrer('Eudora/6.2.3b9 (MacOS)').email).to eq('Eudora')
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should detect T-Online eMail" do
|
75
|
-
UseragentParser.parse_with_referrer('Kopernikus T-Online eMail 3.x').email.
|
75
|
+
expect(UseragentParser.parse_with_referrer('Kopernikus T-Online eMail 3.x').email).to eq('T-Online eMail')
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should detect old Apple Mail" do
|
79
|
-
UseragentParser.parse_with_referrer('Mail/1082 CFNetwork/454.11.5 Darwin/10.5.0 (i386) (MacBookPro6%2C2)').email.
|
79
|
+
expect(UseragentParser.parse_with_referrer('Mail/1082 CFNetwork/454.11.5 Darwin/10.5.0 (i386) (MacBookPro6%2C2)').email).to eq('Apple Mail')
|
80
80
|
end
|
81
81
|
|
82
82
|
it "should detect newer Apple Mail" do
|
83
|
-
UseragentParser.parse_with_referrer('Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; de-de) AppleWebKit/533.18.1 (KHTML, like Gecko)').email.
|
83
|
+
expect(UseragentParser.parse_with_referrer('Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; de-de) AppleWebKit/533.18.1 (KHTML, like Gecko)').email).to eq('Apple Mail')
|
84
84
|
end
|
85
85
|
|
86
86
|
it "should detect Lotus Notes" do
|
87
|
-
UseragentParser.parse_with_referrer('Mozilla/4.0 (compatible; Lotus-Notes/6.0; Macintosh PPC)').email.
|
87
|
+
expect(UseragentParser.parse_with_referrer('Mozilla/4.0 (compatible; Lotus-Notes/6.0; Macintosh PPC)').email).to eq('Lotus Notes')
|
88
88
|
end
|
89
89
|
|
90
90
|
it "should detect Microsoft Outlook" do
|
91
|
-
UseragentParser.parse_with_referrer('Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 1.1.4322; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; ms-office; MSOffice 14)').email.
|
91
|
+
expect(UseragentParser.parse_with_referrer('Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 1.1.4322; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; ms-office; MSOffice 14)').email).to eq('Microsoft Outlook')
|
92
92
|
end
|
93
93
|
|
94
94
|
it "should detect Sparrow" do
|
95
|
-
UseragentParser.parse_with_referrer('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8) AppleWebKit/536.25 (KHTML, like Gecko) Sparrow/1164').email.
|
95
|
+
expect(UseragentParser.parse_with_referrer('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8) AppleWebKit/536.25 (KHTML, like Gecko) Sparrow/1164').email).to eq('Sparrow')
|
96
96
|
end
|
97
97
|
|
98
98
|
describe "Outlook" do
|
99
99
|
it "should should recognize Outlook 2000/2003/Express" do
|
100
|
-
UseragentParser.parse_with_referrer('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)').email_version.
|
100
|
+
expect(UseragentParser.parse_with_referrer('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)').email_version).to eq('Outlook 2000/2003/Express')
|
101
101
|
end
|
102
102
|
|
103
103
|
it "should not mistake IE7 as Outlook" do
|
@@ -105,204 +105,204 @@ describe UseragentParser::UserAgent do
|
|
105
105
|
end
|
106
106
|
|
107
107
|
it "should should recognize Outlook 2007" do
|
108
|
-
UseragentParser.parse_with_referrer('Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; MSOffice 12)').email_version.
|
108
|
+
expect(UseragentParser.parse_with_referrer('Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; MSOffice 12)').email_version).to eq('Outlook 2007')
|
109
109
|
end
|
110
110
|
|
111
111
|
it "should should recognize Outlook 2010" do
|
112
|
-
UseragentParser.parse_with_referrer('Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; InfoPath.3; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E; ms-office; MSOffice 14)').email_version.
|
112
|
+
expect(UseragentParser.parse_with_referrer('Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; InfoPath.3; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E; ms-office; MSOffice 14)').email_version).to eq('Outlook 2010')
|
113
113
|
end
|
114
114
|
|
115
115
|
it "should should recognize Outlook 2013" do
|
116
|
-
UseragentParser.parse_with_referrer('Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; Tablet PC 2.0; InfoPath.3; BOIE9;ENIN; Microsoft Outlook 15.0.4128; ms-office; MSOffice 15)').email_version.
|
116
|
+
expect(UseragentParser.parse_with_referrer('Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; Tablet PC 2.0; InfoPath.3; BOIE9;ENIN; Microsoft Outlook 15.0.4128; ms-office; MSOffice 15)').email_version).to eq('Outlook 2013')
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
120
120
|
describe "Apple Mail" do
|
121
121
|
it "should recognize Version 2" do
|
122
|
-
UseragentParser.parse_with_referrer('Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; de-de) AppleWebKit/533.19.4 (KHTML, like Gecko)').email_version.
|
122
|
+
expect(UseragentParser.parse_with_referrer('Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; de-de) AppleWebKit/533.19.4 (KHTML, like Gecko)').email_version).to eq('Apple Mail 2')
|
123
123
|
end
|
124
124
|
|
125
125
|
it "should recognize Version 3" do
|
126
|
-
UseragentParser.parse_with_referrer('Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_5_8; de-de) AppleWebKit/533.18.1 (KHTML, like Gecko)').email_version.
|
126
|
+
expect(UseragentParser.parse_with_referrer('Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_5_8; de-de) AppleWebKit/533.18.1 (KHTML, like Gecko)').email_version).to eq('Apple Mail 3')
|
127
127
|
end
|
128
128
|
|
129
129
|
it "should recognize Version 4" do
|
130
|
-
UseragentParser.parse_with_referrer('Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; de-de) AppleWebKit/533.19.4 (KHTML, like Gecko)').email_version.
|
130
|
+
expect(UseragentParser.parse_with_referrer('Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; de-de) AppleWebKit/533.19.4 (KHTML, like Gecko)').email_version).to eq('Apple Mail 4')
|
131
131
|
end
|
132
132
|
|
133
133
|
it "should recognize Version 5" do
|
134
|
-
UseragentParser.parse_with_referrer('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/534.53.11 (KHTML, like Gecko)').email_version.
|
134
|
+
expect(UseragentParser.parse_with_referrer('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/534.53.11 (KHTML, like Gecko)').email_version).to eq('Apple Mail 5')
|
135
135
|
end
|
136
136
|
|
137
137
|
it "should recognize Version 6" do
|
138
|
-
UseragentParser.parse_with_referrer('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_1) AppleWebKit/536.25 (KHTML, like Gecko)').email_version.
|
138
|
+
expect(UseragentParser.parse_with_referrer('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_1) AppleWebKit/536.25 (KHTML, like Gecko)').email_version).to eq('Apple Mail 6')
|
139
139
|
end
|
140
140
|
|
141
141
|
it "should not mistake Safari for Apple Mail" do
|
142
|
-
UseragentParser.parse_with_referrer('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_1) AppleWebKit/536.25 (KHTML, like Gecko)', 'something').email_version.
|
142
|
+
expect(UseragentParser.parse_with_referrer('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_1) AppleWebKit/536.25 (KHTML, like Gecko)', 'something').email_version).to be_nil
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
146
146
|
describe "Apple Mobile Mail" do
|
147
147
|
it "should recognize iOS 2" do
|
148
|
-
UseragentParser.parse_with_referrer('Mozilla/5.0 (iPhone; U; CPU iPhone OS 2_1 like Mac OS X; de-de) AppleWebKit/525.18.1 (KHTML, like Gecko)').email_version.
|
148
|
+
expect(UseragentParser.parse_with_referrer('Mozilla/5.0 (iPhone; U; CPU iPhone OS 2_1 like Mac OS X; de-de) AppleWebKit/525.18.1 (KHTML, like Gecko)').email_version).to eq('Apple Mobile Mail 2')
|
149
149
|
end
|
150
150
|
|
151
151
|
it "should recognize iOS 3" do
|
152
|
-
UseragentParser.parse_with_referrer('Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_3 like Mac OS X; de-de) AppleWebKit/528.18 (KHTML, like Gecko)').email_version.
|
152
|
+
expect(UseragentParser.parse_with_referrer('Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_3 like Mac OS X; de-de) AppleWebKit/528.18 (KHTML, like Gecko)').email_version).to eq('Apple Mobile Mail 3')
|
153
153
|
end
|
154
154
|
|
155
155
|
it "should recognize iOS 4" do
|
156
|
-
UseragentParser.parse_with_referrer('Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_1 like Mac OS X; de-de) AppleWebKit/533.17.9 (KHTML, like Gecko)').email_version.
|
156
|
+
expect(UseragentParser.parse_with_referrer('Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_1 like Mac OS X; de-de) AppleWebKit/533.17.9 (KHTML, like Gecko)').email_version).to eq('Apple Mobile Mail 4')
|
157
157
|
end
|
158
158
|
|
159
159
|
it "should recognize iOS 5" do
|
160
|
-
UseragentParser.parse_with_referrer('Mozilla/5.0 (iPad; CPU OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko)').email_version.
|
160
|
+
expect(UseragentParser.parse_with_referrer('Mozilla/5.0 (iPad; CPU OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko)').email_version).to eq('Apple Mobile Mail 5')
|
161
161
|
end
|
162
162
|
|
163
163
|
it "should recognize iOS 2" do
|
164
|
-
UseragentParser.parse_with_referrer('Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/535.8 (KHTML, like Gecko)').email_version.
|
164
|
+
expect(UseragentParser.parse_with_referrer('Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/535.8 (KHTML, like Gecko)').email_version).to eq('Apple Mobile Mail 6')
|
165
165
|
end
|
166
166
|
|
167
167
|
it "should not mistake Mobile Safari for Apple Mail" do
|
168
|
-
UseragentParser.parse_with_referrer('Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/535.8 (KHTML, like Gecko)', 'http://example.com').email_version.
|
168
|
+
expect(UseragentParser.parse_with_referrer('Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/535.8 (KHTML, like Gecko)', 'http://example.com').email_version).to be_nil
|
169
169
|
end
|
170
170
|
end
|
171
171
|
|
172
172
|
describe "AOL" do
|
173
173
|
it "should recognize the Webmail interface" do
|
174
|
-
UseragentParser.parse_with_referrer('Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.13) Gecko/20101203 AskTbFXTV5/3.9.1.14019 Firefox/3.6.13', 'http://mail.aol.com/33222-111/aol-1/de-de/Lite/MsgRead.aspx?folder=Spam&uid=1.28305313&seq=0&searchIn=none&searchQuery=&start=0&sort=received').email.
|
174
|
+
expect(UseragentParser.parse_with_referrer('Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.13) Gecko/20101203 AskTbFXTV5/3.9.1.14019 Firefox/3.6.13', 'http://mail.aol.com/33222-111/aol-1/de-de/Lite/MsgRead.aspx?folder=Spam&uid=1.28305313&seq=0&searchIn=none&searchQuery=&start=0&sort=received').email).to eq('AOL Webmail')
|
175
175
|
end
|
176
176
|
end
|
177
177
|
end
|
178
178
|
|
179
179
|
describe "for operating system details" do
|
180
180
|
it "should report the os family" do
|
181
|
-
UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows NT', 'major' => '3', 'minor' => '1' } }).os_family.
|
181
|
+
expect(UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows NT', 'major' => '3', 'minor' => '1' } }).os_family).to eq('Windows NT')
|
182
182
|
end
|
183
183
|
|
184
184
|
it "should report the major os version" do
|
185
|
-
UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows NT', 'major' => '3', 'minor' => '1' } }).os_major_version.
|
185
|
+
expect(UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows NT', 'major' => '3', 'minor' => '1' } }).os_major_version).to eq('3')
|
186
186
|
end
|
187
187
|
|
188
188
|
it "should report the minor os version" do
|
189
|
-
UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows NT', 'major' => '3', 'minor' => '1' } }).os_minor_version.
|
189
|
+
expect(UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows NT', 'major' => '3', 'minor' => '1' } }).os_minor_version).to eq('1')
|
190
190
|
end
|
191
191
|
|
192
192
|
it "should report the os patchlevel" do
|
193
|
-
UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows NT', 'major' => '3', 'minor' => '1' } }).os_patch_version.
|
193
|
+
expect(UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows NT', 'major' => '3', 'minor' => '1' } }).os_patch_version).to be_nil
|
194
194
|
end
|
195
195
|
|
196
196
|
it "should report the os version" do
|
197
|
-
UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows NT', 'major' => '3', 'minor' => '1' } }).os_version.
|
197
|
+
expect(UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows NT', 'major' => '3', 'minor' => '1' } }).os_version).to eq('3.1')
|
198
198
|
end
|
199
199
|
|
200
200
|
it "should know the code name for Windows NT 3.1" do
|
201
|
-
UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows NT', 'major' => '3', 'minor' => '1' } }).os.
|
201
|
+
expect(UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows NT', 'major' => '3', 'minor' => '1' } }).os).to eq('Microsoft Windows NT 3.1')
|
202
202
|
end
|
203
203
|
|
204
204
|
it "should know the code name for Windows NT 3.5" do
|
205
|
-
UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows NT', 'major' => '3', 'minor' => '5' } }).os.
|
205
|
+
expect(UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows NT', 'major' => '3', 'minor' => '5' } }).os).to eq('Microsoft Windows NT 3.5')
|
206
206
|
end
|
207
207
|
|
208
208
|
it "should know the code name for Windows NT 4.0" do
|
209
|
-
UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows NT', 'major' => '4', 'minor' => '0' } }).os.
|
209
|
+
expect(UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows NT', 'major' => '4', 'minor' => '0' } }).os).to eq('Microsoft Windows NT 4.0')
|
210
210
|
end
|
211
211
|
|
212
212
|
it "should know the code name for Windows 2000" do
|
213
|
-
UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows NT', 'major' => '5', 'minor' => '0' } }).os.
|
213
|
+
expect(UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows NT', 'major' => '5', 'minor' => '0' } }).os).to eq('Microsoft Windows 2000')
|
214
214
|
end
|
215
215
|
|
216
216
|
it "should know the code name for Windows XP" do
|
217
|
-
UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows NT', 'major' => '5', 'minor' => '1' } }).os.
|
217
|
+
expect(UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows NT', 'major' => '5', 'minor' => '1' } }).os).to eq('Microsoft Windows XP')
|
218
218
|
end
|
219
219
|
|
220
220
|
it "should know the code name for Windows XP 64bit / Server 2003" do
|
221
|
-
UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows NT', 'major' => '5', 'minor' => '2' } }).os.
|
221
|
+
expect(UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows NT', 'major' => '5', 'minor' => '2' } }).os).to eq('Microsoft Windows XP 64bit / Server 2003')
|
222
222
|
end
|
223
223
|
|
224
224
|
it "should know the code name for Windows Vista / Server 2008" do
|
225
|
-
UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows NT', 'major' => '6', 'minor' => '0' } }).os.
|
225
|
+
expect(UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows NT', 'major' => '6', 'minor' => '0' } }).os).to eq('Microsoft Windows Vista / Server 2008')
|
226
226
|
end
|
227
227
|
|
228
228
|
it "should know the code name for Windows 7 / Server 2008 R2" do
|
229
|
-
UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows NT', 'major' => '6', 'minor' => '1' } }).os.
|
229
|
+
expect(UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows NT', 'major' => '6', 'minor' => '1' } }).os).to eq('Microsoft Windows 7 / Server 2008 R2')
|
230
230
|
end
|
231
231
|
|
232
232
|
it "should know the code name for Windows 8" do
|
233
|
-
UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows NT', 'major' => '6', 'minor' => '2' } }).os.
|
233
|
+
expect(UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows NT', 'major' => '6', 'minor' => '2' } }).os).to eq('Microsoft Windows 8')
|
234
234
|
end
|
235
235
|
|
236
236
|
it "should know the code name for Windows 3.1" do
|
237
|
-
UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows', 'major' => '3', 'minor' => '1' } }).os.
|
237
|
+
expect(UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows', 'major' => '3', 'minor' => '1' } }).os).to eq('Microsoft Windows 3.1')
|
238
238
|
end
|
239
239
|
|
240
240
|
it "should know the code name for Windows 95" do
|
241
|
-
UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows', 'major' => '95' } }).os.
|
241
|
+
expect(UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows', 'major' => '95' } }).os).to eq('Microsoft Windows 95')
|
242
242
|
end
|
243
243
|
|
244
244
|
it "should know the code name for Windows 98" do
|
245
|
-
UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows', 'major' => '98' } }).os.
|
245
|
+
expect(UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows', 'major' => '98' } }).os).to eq('Microsoft Windows 98')
|
246
246
|
end
|
247
247
|
|
248
248
|
it "should know the code name for Windows ME" do
|
249
|
-
UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows', 'major' => 'ME' } }).os.
|
249
|
+
expect(UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows', 'major' => 'ME' } }).os).to eq('Microsoft Windows ME')
|
250
250
|
end
|
251
251
|
|
252
252
|
it "should know the code name for Windows 9x" do
|
253
|
-
UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows', 'major' => '9x' } }).os.
|
253
|
+
expect(UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Windows', 'major' => '9x' } }).os).to eq('Microsoft Windows 9x')
|
254
254
|
end
|
255
255
|
|
256
256
|
it "should know the code name for Mac OS X 10.0" do
|
257
|
-
UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Mac OS X', 'major' => '10', 'minor' => '0' } }).os.
|
257
|
+
expect(UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Mac OS X', 'major' => '10', 'minor' => '0' } }).os).to eq('Apple Mac OS X 10.0 (Cheetah)')
|
258
258
|
end
|
259
259
|
|
260
260
|
it "should know the code name for Mac OS X 10.0" do
|
261
|
-
UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Mac OS X', 'major' => '10', 'minor' => '0', 'patch' => 2 } }).os.
|
261
|
+
expect(UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Mac OS X', 'major' => '10', 'minor' => '0', 'patch' => 2 } }).os).to eq('Apple Mac OS X 10.0.2 (Cheetah)')
|
262
262
|
end
|
263
263
|
|
264
264
|
it "should know the code name for Mac OS X 10.1" do
|
265
|
-
UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Mac OS X', 'major' => '10', 'minor' => '1', 'patch' => 2 } }).os.
|
265
|
+
expect(UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Mac OS X', 'major' => '10', 'minor' => '1', 'patch' => 2 } }).os).to eq('Apple Mac OS X 10.1.2 (Puma)')
|
266
266
|
end
|
267
267
|
|
268
268
|
it "should know the code name for Mac OS X 10.2" do
|
269
|
-
UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Mac OS X', 'major' => '10', 'minor' => '2', 'patch' => 2 } }).os.
|
269
|
+
expect(UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Mac OS X', 'major' => '10', 'minor' => '2', 'patch' => 2 } }).os).to eq('Apple Mac OS X 10.2.2 (Jaguar)')
|
270
270
|
end
|
271
271
|
|
272
272
|
it "should know the code name for Mac OS X 10.3" do
|
273
|
-
UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Mac OS X', 'major' => '10', 'minor' => '3', 'patch' => 2 } }).os.
|
273
|
+
expect(UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Mac OS X', 'major' => '10', 'minor' => '3', 'patch' => 2 } }).os).to eq('Apple Mac OS X 10.3.2 (Panther)')
|
274
274
|
end
|
275
275
|
|
276
276
|
it "should know the code name for Mac OS X 10.4" do
|
277
|
-
UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Mac OS X', 'major' => '10', 'minor' => '4', 'patch' => 2 } }).os.
|
277
|
+
expect(UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Mac OS X', 'major' => '10', 'minor' => '4', 'patch' => 2 } }).os).to eq('Apple Mac OS X 10.4.2 (Tiger)')
|
278
278
|
end
|
279
279
|
|
280
280
|
it "should know the code name for Mac OS X 10.5" do
|
281
|
-
UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Mac OS X', 'major' => '10', 'minor' => '5', 'patch' => 2 } }).os.
|
281
|
+
expect(UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Mac OS X', 'major' => '10', 'minor' => '5', 'patch' => 2 } }).os).to eq('Apple Mac OS X 10.5.2 (Leopard)')
|
282
282
|
end
|
283
283
|
|
284
284
|
it "should know the code name for Mac OS X 10.6" do
|
285
|
-
UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Mac OS X', 'major' => '10', 'minor' => '6', 'patch' => 2 } }).os.
|
285
|
+
expect(UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Mac OS X', 'major' => '10', 'minor' => '6', 'patch' => 2 } }).os).to eq('Apple Mac OS X 10.6.2 (Snow Leopard)')
|
286
286
|
end
|
287
287
|
|
288
288
|
it "should know the code name for Mac OS X 10.7" do
|
289
|
-
UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Mac OS X', 'major' => '10', 'minor' => '7', 'patch' => '2' } }).os.
|
289
|
+
expect(UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Mac OS X', 'major' => '10', 'minor' => '7', 'patch' => '2' } }).os).to eq('Apple Mac OS X 10.7.2 (Lion)')
|
290
290
|
end
|
291
291
|
|
292
292
|
it "should provide a generic os/version for other operating systems" do
|
293
|
-
UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Linux', 'major' => '2', 'minor' => '6', 'patch' => '32' } }).os.
|
293
|
+
expect(UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Linux', 'major' => '2', 'minor' => '6', 'patch' => '32' } }).os).to eq('Linux 2.6.32')
|
294
294
|
end
|
295
295
|
|
296
296
|
it "should provide a generic os name without version" do
|
297
|
-
UseragentParser::UserAgent.new({ 'os' => { 'family' => 'FreeBSD' } }).os.
|
297
|
+
expect(UseragentParser::UserAgent.new({ 'os' => { 'family' => 'FreeBSD' } }).os).to eq('FreeBSD')
|
298
298
|
end
|
299
299
|
end
|
300
300
|
|
301
301
|
it "should combing operating system and browser version" do
|
302
302
|
ua = UseragentParser::UserAgent.new({ 'os' => { 'family' => 'Mac OS X', 'major' => '10', 'minor' => '7', 'patch' => '2' }, 'user_agent' => { 'family' => 'Chrome', 'major' => '14', 'minor' => '0', 'patch' => '835' } })
|
303
|
-
ua.browser_family.
|
304
|
-
ua.browser_version.
|
305
|
-
ua.os_family.
|
306
|
-
ua.os_version.
|
303
|
+
expect(ua.browser_family).to eq('Chrome')
|
304
|
+
expect(ua.browser_version).to eq('14.0.835')
|
305
|
+
expect(ua.os_family).to eq('Mac OS X')
|
306
|
+
expect(ua.os_version).to eq('10.7.2')
|
307
307
|
end
|
308
308
|
end
|
@@ -8,27 +8,72 @@ describe UseragentParser do
|
|
8
8
|
describe "should return user agent information" do
|
9
9
|
subject { UseragentParser.parse_browser(user_agent_string)['user_agent'] }
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
describe "['family']" do
|
12
|
+
subject { super()['family'] }
|
13
|
+
it { is_expected.to eq('Firefox') }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "['major']" do
|
17
|
+
subject { super()['major'] }
|
18
|
+
it { is_expected.to eq('3') }
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "['minor']" do
|
22
|
+
subject { super()['minor'] }
|
23
|
+
it { is_expected.to eq('5') }
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "['patch']" do
|
27
|
+
subject { super()['patch'] }
|
28
|
+
it { is_expected.to eq('5') }
|
29
|
+
end
|
15
30
|
end
|
16
31
|
|
17
32
|
describe "should return the operating system information" do
|
18
33
|
subject { UseragentParser.parse_browser(user_agent_string)['os'] }
|
19
34
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
35
|
+
describe "['family']" do
|
36
|
+
subject { super()['family'] }
|
37
|
+
it { is_expected.to eq('Mac OS X') }
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "['major']" do
|
41
|
+
subject { super()['major'] }
|
42
|
+
it { is_expected.to eq('10') }
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "['minor']" do
|
46
|
+
subject { super()['minor'] }
|
47
|
+
it { is_expected.to eq('4') }
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "['patch']" do
|
51
|
+
subject { super()['patch'] }
|
52
|
+
it { is_expected.to be_nil }
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "['patch_minor']" do
|
56
|
+
subject { super()['patch_minor'] }
|
57
|
+
it { is_expected.to be_nil }
|
58
|
+
end
|
25
59
|
end
|
26
60
|
|
27
61
|
describe "should return the device information" do
|
28
62
|
subject { UseragentParser.parse_browser(user_agent_string)['device'] }
|
29
63
|
|
30
|
-
|
31
|
-
|
32
|
-
|
64
|
+
describe "['family']" do
|
65
|
+
subject { super()['family'] }
|
66
|
+
it { is_expected.to be_nil }
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "['is_spider']" do
|
70
|
+
subject { super()['is_spider'] }
|
71
|
+
it { is_expected.to be_falsey }
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "['is_mobile']" do
|
75
|
+
subject { super()['is_mobile'] }
|
76
|
+
it { is_expected.to be_falsey }
|
77
|
+
end
|
33
78
|
end
|
34
79
|
end
|
data/useragent_parser.gemspec
CHANGED
@@ -19,7 +19,6 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
21
|
# specify any dependencies here; for example:
|
22
|
-
s.add_development_dependency "rake"
|
23
|
-
s.add_development_dependency "rspec", "~>
|
24
|
-
s.add_development_dependency "multi_json", "~> 1.0.1"
|
22
|
+
s.add_development_dependency "rake"
|
23
|
+
s.add_development_dependency "rspec", "~> 3.0"
|
25
24
|
end
|
metadata
CHANGED
@@ -1,64 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: useragent_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Morton Jonuschat
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-07-25 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
|
-
version: 0
|
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
|
-
version: 0
|
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
|
-
version:
|
33
|
+
version: '3.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
|
-
version:
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: multi_json
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ~>
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: 1.0.1
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 1.0.1
|
40
|
+
version: '3.0'
|
62
41
|
description: UseragentParser extracts browser and operating system information from
|
63
42
|
the headers sent by most browsers and email clients
|
64
43
|
email:
|
@@ -67,8 +46,8 @@ executables: []
|
|
67
46
|
extensions: []
|
68
47
|
extra_rdoc_files: []
|
69
48
|
files:
|
70
|
-
- .gitignore
|
71
|
-
- .travis.yml
|
49
|
+
- ".gitignore"
|
50
|
+
- ".travis.yml"
|
72
51
|
- Gemfile
|
73
52
|
- LICENSE
|
74
53
|
- README.md
|
@@ -99,27 +78,26 @@ files:
|
|
99
78
|
- useragent_parser.gemspec
|
100
79
|
homepage: https://github.com/yabawock/useragent_parser
|
101
80
|
licenses: []
|
81
|
+
metadata: {}
|
102
82
|
post_install_message:
|
103
83
|
rdoc_options: []
|
104
84
|
require_paths:
|
105
85
|
- lib
|
106
86
|
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
-
none: false
|
108
87
|
requirements:
|
109
|
-
- -
|
88
|
+
- - ">="
|
110
89
|
- !ruby/object:Gem::Version
|
111
90
|
version: '0'
|
112
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
92
|
requirements:
|
115
|
-
- -
|
93
|
+
- - ">="
|
116
94
|
- !ruby/object:Gem::Version
|
117
95
|
version: '0'
|
118
96
|
requirements: []
|
119
97
|
rubyforge_project: useragent_parser
|
120
|
-
rubygems_version:
|
98
|
+
rubygems_version: 2.2.2
|
121
99
|
signing_key:
|
122
|
-
specification_version:
|
100
|
+
specification_version: 4
|
123
101
|
summary: A library to extract informtion from Useragent headers
|
124
102
|
test_files:
|
125
103
|
- spec/fixtures/additional_os_tests.yaml
|