useragent_parser 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,34 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe UseragentParser do
6
+ let(:user_agent_string) { 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; fr; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5,gzip(gfe),gzip(gfe)' }
7
+
8
+ describe "should return user agent information" do
9
+ subject { UseragentParser.parse_all(user_agent_string)['user_agent'] }
10
+
11
+ its(['family']) { should == 'Firefox' }
12
+ its(['major']) { should == '3' }
13
+ its(['minor']) { should == '5' }
14
+ its(['patch']) { should == '5' }
15
+ end
16
+
17
+ describe "should return the operating system information" do
18
+ subject { UseragentParser.parse_all(user_agent_string)['os'] }
19
+
20
+ its(['family']) { should == 'Mac OS X' }
21
+ its(['major']) { should == '10' }
22
+ its(['minor']) { should == '4' }
23
+ its(['patch']) { should be_nil }
24
+ its(['patch_minor']) { should be_nil }
25
+ end
26
+
27
+ describe "should return the device information" do
28
+ subject { UseragentParser.parse_all(user_agent_string)['device'] }
29
+
30
+ its(['family']) { should be_nil }
31
+ its(['is_spider']) { should be_false }
32
+ its(['is_mobile']) { should be_false }
33
+ end
34
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: useragent_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-23 00:00:00.000000000Z
12
+ date: 2012-09-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70218494984620 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: 0.9.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70218494984620
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.9.0
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rspec
27
- requirement: &70218495033460 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ~>
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: 2.6.0
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *70218495033460
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 2.6.0
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: multi_json
38
- requirement: &70218495032760 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ~>
@@ -43,7 +53,12 @@ dependencies:
43
53
  version: 1.0.1
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *70218495032760
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.1
47
62
  description: UseragentParser extracts browser and operating system information from
48
63
  the headers sent by most browsers and email clients
49
64
  email:
@@ -58,17 +73,25 @@ files:
58
73
  - LICENSE
59
74
  - README.md
60
75
  - Rakefile
61
- - config/user_agent_parser.yaml
76
+ - config/regexes.yaml
62
77
  - lib/useragent_parser.rb
63
- - lib/useragent_parser/parser.rb
78
+ - lib/useragent_parser/parsers/device_parser.rb
79
+ - lib/useragent_parser/parsers/os_parser.rb
80
+ - lib/useragent_parser/parsers/user_agent_parser.rb
64
81
  - lib/useragent_parser/user_agent.rb
65
82
  - lib/useragent_parser/version.rb
83
+ - spec/fixtures/additional_os_tests.yaml
66
84
  - spec/fixtures/firefox_user_agent_strings.yaml
67
85
  - spec/fixtures/pgts_browser_list.yaml
86
+ - spec/fixtures/test_device.yaml
68
87
  - spec/fixtures/test_user_agent_parser.yaml
88
+ - spec/fixtures/test_user_agent_parser_os.yaml
89
+ - spec/parsers/device_parser_spec.rb
90
+ - spec/parsers/os_parser_spec.rb
91
+ - spec/parsers/useragent_parser_spec.rb
69
92
  - spec/spec_helper.rb
70
- - spec/useragent_parser/user_agent_spec.rb
71
- - spec/useragent_parser/useragent_parser_spec.rb
93
+ - spec/user_agent_spec.rb
94
+ - spec/useragent_parser_spec.rb
72
95
  - useragent_parser.gemspec
73
96
  homepage: https://github.com/yabawock/useragent_parser
74
97
  licenses: []
@@ -82,28 +105,28 @@ required_ruby_version: !ruby/object:Gem::Requirement
82
105
  - - ! '>='
83
106
  - !ruby/object:Gem::Version
84
107
  version: '0'
85
- segments:
86
- - 0
87
- hash: -1051950562318165295
88
108
  required_rubygems_version: !ruby/object:Gem::Requirement
89
109
  none: false
90
110
  requirements:
91
111
  - - ! '>='
92
112
  - !ruby/object:Gem::Version
93
113
  version: '0'
94
- segments:
95
- - 0
96
- hash: -1051950562318165295
97
114
  requirements: []
98
115
  rubyforge_project: useragent_parser
99
- rubygems_version: 1.8.6
116
+ rubygems_version: 1.8.23
100
117
  signing_key:
101
118
  specification_version: 3
102
119
  summary: A library to extract informtion from Useragent headers
103
120
  test_files:
121
+ - spec/fixtures/additional_os_tests.yaml
104
122
  - spec/fixtures/firefox_user_agent_strings.yaml
105
123
  - spec/fixtures/pgts_browser_list.yaml
124
+ - spec/fixtures/test_device.yaml
106
125
  - spec/fixtures/test_user_agent_parser.yaml
126
+ - spec/fixtures/test_user_agent_parser_os.yaml
127
+ - spec/parsers/device_parser_spec.rb
128
+ - spec/parsers/os_parser_spec.rb
129
+ - spec/parsers/useragent_parser_spec.rb
107
130
  - spec/spec_helper.rb
108
- - spec/useragent_parser/user_agent_spec.rb
109
- - spec/useragent_parser/useragent_parser_spec.rb
131
+ - spec/user_agent_spec.rb
132
+ - spec/useragent_parser_spec.rb
@@ -1,259 +0,0 @@
1
- user_agent_parsers:
2
- #### SPECIAL CASES TOP ####
3
-
4
- # must go before Opera
5
- - regex: '^(Opera)/(\d+)\.(\d+) \(Nintendo Wii'
6
- family_replacement: 'Wii'
7
-
8
- # must go before Firefox to catch SeaMonkey.
9
- - regex: '(SeaMonkey|Fennec|Camino)/(\d+)\.(\d+)\.?([ab]?\d+[a-z]*)'
10
-
11
- # must go before Firefox
12
-
13
- # must go before Browser/major_version.minor_version - eg: Minefield/3.1a1pre
14
- - regex: '(Namoroka|Shiretoko|Minefield)/(\d+)\.(\d+)\.(\d+(?:pre)?)'
15
- family_replacement: 'Firefox ($1)'
16
-
17
- - regex: '(Firefox)/(\d+)\.(\d+)([ab]\d+[a-z]*)'
18
- family_replacement: 'Firefox Beta'
19
-
20
- - regex: '(Firefox)-(?:\d+\.\d+)?/(\d+)\.(\d+)([ab]\d+[a-z]*)'
21
- family_replacement: 'Firefox Beta'
22
-
23
- - regex: '(Namoroka|Shiretoko|Minefield)/(\d+)\.(\d+)([ab]\d+[a-z]*)?'
24
- family_replacement: 'Firefox ($1)'
25
-
26
- - regex: '(Firefox).*Tablet browser (\d+)\.(\d+)\.(\d+)'
27
- family_replacement: 'MicroB'
28
-
29
- - regex: '(MozillaDeveloperPreview)/(\d+)\.(\d+)([ab]\d+[a-z]*)?'
30
-
31
- # e.g.: Flock/2.0b2
32
- - regex: '(Flock)/(\d+)\.(\d+)(b\d+?)'
33
-
34
- # RockMelt
35
- - regex: '(RockMelt)/(\d+)\.(\d+)\.(\d+)'
36
-
37
- # e.g.: Fennec/0.9pre
38
- - regex: '(Fennec)/(\d+)\.(\d+)(pre)'
39
-
40
- - regex: '(Navigator)/(\d+)\.(\d+)\.(\d+)'
41
- family_replacement: 'Netscape'
42
-
43
- - regex: '(Navigator)/(\d+)\.(\d+)([ab]\d+)'
44
- family_replacement: 'Netscape'
45
-
46
- - regex: '(Netscape6)/(\d+)\.(\d+)\.(\d+)'
47
- family_replacement: 'Netscape'
48
-
49
- - regex: '(MyIBrow)/(\d+)\.(\d+)'
50
- family_replacement: 'My Internet Browser'
51
-
52
- # Opera will stop at 9.80 and hide the real version in the Version string.
53
- # see: http://dev.opera.com/articles/view/opera-ua-string-changes/
54
- - regex: '(Opera Tablet).*Version\/(\d+)\.(\d+)(?:\.(\d+))?'
55
-
56
- - regex: '(Opera)/.+Opera Mobi.+Version/(\d+)\.(\d+)'
57
- family_replacement: 'Opera Mobile'
58
-
59
- - regex: '(Opera Mini)/(\d+)\.(\d+)'
60
-
61
- - regex: '(Opera)/9.80.*Version\/(\d+)\.(\d+)(?:\.(\d+))?'
62
-
63
- # Palm WebOS looks a lot like Safari.
64
- - regex: '(webOS)/(\d+)\.(\d+)'
65
- family_replacement: 'Palm webOS'
66
-
67
- # LuaKit has no version info.
68
- # http://luakit.org/projects/luakit/
69
- - regex: '(luakit)'
70
- family_replacement: 'LuaKit'
71
-
72
- # Lightning (for Thunderbird)
73
- # http://www.mozilla.org/projects/calendar/lightning/
74
- - regex: '(Lightning)/(\d+)\.(\d+)([ab]?\d+[a-z]*)'
75
-
76
- # Swiftfox
77
- - regex: '(Firefox)/(\d+)\.(\d+)\.(\d+(?:pre)?) \(Swiftfox\)'
78
- family_replacement: 'Swiftfox'
79
- - regex: '(Firefox)/(\d+)\.(\d+)([ab]\d+[a-z]*)? \(Swiftfox\)'
80
- family_replacement: 'Swiftfox'
81
-
82
- # Rekonq
83
- - regex: 'rekonq'
84
- family_replacement: 'Rekonq'
85
-
86
- # Conkeror lowercase/uppercase
87
- # http://conkeror.org/
88
- - regex: '(conkeror|Conkeror)/(\d+)\.(\d+)\.?(\d+)?'
89
- family_replacement: 'Conkeror'
90
-
91
- # catches lower case konqueror
92
- - regex: '(konqueror)/(\d+)\.(\d+)\.(\d+)'
93
- family_replacement: 'Konqueror'
94
-
95
- - regex: '(PlayBook).+RIM Tablet OS (\d+)\.(\d+)\.(\d+)'
96
-
97
- - regex: '(WeTab)-Browser'
98
-
99
- - regex: '(wOSBrowser).+TouchPad/(\d+)\.(\d+)'
100
- family_replacement: 'webOS TouchPad'
101
-
102
- - regex: '(Comodo_Dragon)/(\d+)\.(\d+)\.(\d+)'
103
- family_replacement: 'Comodo Dragon'
104
-
105
- # YottaaMonitor bot
106
- - regex: '(YottaaMonitor)'
107
-
108
- # must go before NetFront below
109
- - regex: '(Kindle)/(\d+)\.(\d+)'
110
-
111
- # Maxthon Googlebot
112
- - regex: 'Googlebot\/\d+\.\d+.+(Maxthon)'
113
-
114
- # Mobile Safari on Android
115
- - regex: 'Android.*\).*(Version)/(\d+)\.(\d+)(?:\.(\d+))?.*Safari/'
116
- family_replacement: 'Mobile Safari'
117
-
118
- # Mobile Safari on iOS
119
- - regex: '(Version)/(\d+)\.(\d+)(?:\.(\d+))?.*Mobile/\w+ Safari/\d+'
120
- family_replacement: 'Mobile Safari'
121
-
122
- #### END SPECIAL CASES TOP ####
123
-
124
- #### MAIN CASES - this catches > 50% of all browsers ####
125
-
126
- # Browser/major_version.minor_version.beta_version
127
- - regex: '(AdobeAIR|Chromium|FireWeb|Jasmine|ANTGalio|Midori|Fresco|Lobo|PaleMoon|Maxthon|Lynx|OmniWeb|Dillo|Camino|Demeter|Fluid|Fennec|Shiira|Sunrise|Chrome|Flock|Netscape|Lunascape|Epiphany|WebPilot|Vodafone|NetFront|Konqueror|SeaMonkey|Kazehakase|Vienna|Iceape|Iceweasel|IceWeasel|Iron|K-Meleon|Sleipnir|Galeon|GranParadiso|Opera Mini|iCab|NetNewsWire|ThunderBrowse|Thunderbird|Iron|Iris)/(\d+)\.(\d+)\.(\d+)'
128
-
129
- # Browser/major_version.minor_version
130
- - regex: '(Bolt|Jasmine|IEMobile|IceCat|Skyfire|Midori|Maxthon|Lynx|Arora|IBrowse|Dillo|Camino|Shiira|Fennec|Phoenix|Chrome|Flock|Netscape|Lunascape|Epiphany|WebPilot|Opera Mini|Opera|Vodafone|NetFront|Konqueror|Googlebot|SeaMonkey|Kazehakase|Vienna|Iceape|Iceweasel|IceWeasel|Iron|K-Meleon|Sleipnir|Galeon|GranParadiso|iCab|NetNewsWire|Iron|Space Bison|Stainless|Orca|Dolfin|BOLT)/(\d+)\.(\d+)'
131
-
132
- # Browser major_version.minor_version.beta_version (space instead of slash)
133
- - regex: '(iRider|Crazy Browser|SkipStone|iCab|Lunascape|Sleipnir|Maemo Browser) (\d+)\.(\d+)\.(\d+)'
134
- # Browser major_version.minor_version (space instead of slash)
135
- - regex: '(iCab|Lunascape|Opera|Android) (\d+)\.(\d+)\.?(\d+)?'
136
-
137
- - regex: '(IEMobile) (\d+)\.(\d+)'
138
- family_replacement: 'IE Mobile'
139
-
140
- # AFTER THE EDGE CASES ABOVE!
141
- - regex: '(Firefox)/(\d+)\.(\d+)\.(\d+)'
142
-
143
- - regex: '(Firefox)/(\d+)\.(\d+)(pre|[ab]\d+[a-z]*)?'
144
- #### END MAIN CASES ####
145
-
146
- #### SPECIAL CASES ####
147
- - regex: '(Obigo|OBIGO)[^\d]*(\d+)(?:.(\d+))?'
148
- family_replacement: 'Obigo'
149
-
150
- - regex: '(MAXTHON|Maxthon) (\d+)\.(\d+)'
151
- family_replacement: 'Maxthon'
152
-
153
- - regex: '(Maxthon|MyIE2|Uzbl|Shiira)'
154
- major_version_replacement: '0'
155
-
156
- - regex: '(PLAYSTATION) (\d+)'
157
- family_replacement: 'PlayStation'
158
-
159
- - regex: '(PlayStation Portable)[^\d]+(\d+).(\d+)'
160
-
161
- - regex: '(BrowseX) \((\d+)\.(\d+)\.(\d+)'
162
-
163
- - regex: '(POLARIS)/(\d+)\.(\d+)'
164
- family_replacement: 'Polaris'
165
-
166
- - regex: '(BonEcho)/(\d+)\.(\d+)\.(\d+)'
167
- family_replacement: 'Bon Echo'
168
-
169
- - regex: '(iPod).+Version/(\d+)\.(\d+)\.(\d+)'
170
-
171
- - regex: '(iPhone) OS (\d+)_(\d+)(?:_(\d+))?'
172
-
173
- - regex: '(iPad).+ OS (\d+)_(\d+)(?:_(\d+))?'
174
-
175
- - regex: '(Avant)'
176
- major_version_replacement: '1'
177
-
178
- - regex: '(Nokia)[EN]?(\d+)'
179
-
180
- # BlackBerry devices
181
- - regex: '(Black[bB]erry).+Version\/(\d+)\.(\d+)\.(\d+)'
182
- family_replacement: 'Blackberry'
183
-
184
- - regex: '(Black[bB]erry)\s?(\d+)'
185
- family_replacement: 'Blackberry'
186
-
187
- - regex: '(OmniWeb)/v(\d+)\.(\d+)'
188
-
189
- - regex: '(Blazer)/(\d+)\.(\d+)'
190
- family_replacement: 'Palm Blazer'
191
-
192
- - regex: '(Pre)/(\d+)\.(\d+)'
193
- family_replacement: 'Palm Pre'
194
-
195
- - regex: '(Links) \((\d+)\.(\d+)'
196
-
197
- - regex: '(QtWeb) Internet Browser/(\d+)\.(\d+)'
198
-
199
- #- regex: '\(iPad;.+(Version)/(\d+)\.(\d+)(?:\.(\d+))?.*Safari/'
200
- # family_replacement: 'iPad'
201
-
202
- # Safari
203
- - regex: '(Version)/(\d+)\.(\d+)(?:\.(\d+))?.*Safari/'
204
- family_replacement: 'Safari'
205
- # Safari didn't provide "Version/d.d.d" prior to 3.0
206
- - regex: '(Safari)/\d+'
207
-
208
- - regex: '(OLPC)/Update(\d+)\.(\d+)'
209
-
210
- - regex: '(OLPC)/Update()\.(\d+)'
211
- major_version_replacement: '0'
212
-
213
- - regex: '(SamsungSGHi560)'
214
- family_replacement: 'Samsung SGHi560'
215
-
216
- - regex: '^(SonyEricssonK800i)'
217
- family_replacement: 'Sony Ericsson K800i'
218
-
219
- - regex: '(Teleca Q7)'
220
-
221
- - regex: '(MSIE) (\d+)\.(\d+)'
222
- family_replacement: 'IE'
223
-
224
-
225
- os_parsers:
226
- - regex: '(Windows NT|Windows) (\d+)\.(\d+)'
227
- family_replacement: 'Windows'
228
- - regex: '(Windows Phone OS) (\d+)\.(\d+)'
229
- family_replacement: 'Windows Phone'
230
- - regex: '(Windows|Win) (XP|9x|95|98|ME)'
231
- family_replacement: 'Windows'
232
- - regex: '(Windows CE)'
233
- - regex: '(Win)(95|98|9x)'
234
- family_replacement: 'Windows'
235
- - regex: '(Windows)'
236
-
237
- - regex: '(Android) (\d+)\.(\d+)\.(\d+)'
238
- - regex: '(Android) (\d+)\.(\d+)'
239
-
240
- - regex: '(CPU OS|CPU iPhone OS) (\d+)_(\d+)_(\d+) like Mac OS X'
241
- family_replacement: 'iOS'
242
- - regex: '(CPU OS|CPU iPhone OS) (\d+)_(\d+) like Mac OS X'
243
- family_replacement: 'iOS'
244
-
245
- - regex: '(Mac OS X) v?(\d+)\.(\d+)\.?(\d+)?'
246
- - regex: '(Mac OS X) v?(\d+)_(\d+)_?(\d+)?'
247
- - regex: '(Mac OS X)/(\d+)\.(\d+)\.?(\d+)?'
248
- - regex: '(os=Mac) (\d+)\.(\d+)\.(\d+)'
249
- family_replacement: 'Mac OS X'
250
- - regex: '(Mac OS X|Mac_PowerPC|iMac|MacBook|Macintosh|PowerMac)'
251
- family_replacement: 'Mac OS X'
252
-
253
- - regex: '(FreeBSD)'
254
- - regex: '(iPhone Simulator)'
255
-
256
- - regex: '(Linux)'
257
-
258
- product_parsers:
259
- - regex: '(iPhone)'
@@ -1,169 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe UseragentParser::UserAgent do
6
- describe "for browser details" do
7
- it "should report the browser family" do
8
- UseragentParser::UserAgent.new({ 'family' => 'Chrome', 'v1' => '14', 'v2' => '0', 'v3' => '835' }).browser_family.should == 'Chrome'
9
- end
10
-
11
- it "should report the browser major version" do
12
- UseragentParser::UserAgent.new({ 'family' => 'Chrome', 'v1' => '14', 'v2' => '0', 'v3' => '835' }).browser_major_version.should == '14'
13
- end
14
-
15
- it "should report the browser minor version" do
16
- UseragentParser::UserAgent.new({ 'family' => 'Chrome', 'v1' => '14', 'v2' => '0', 'v3' => '835' }).browser_minor_version.should == '0'
17
- end
18
-
19
- it "should report the browser patch version" do
20
- UseragentParser::UserAgent.new({ 'family' => 'Chrome', 'v1' => '14', 'v2' => '0', 'v3' => '835' }).browser_patch_version.should == '835'
21
- end
22
-
23
- it "should report the browser version" do
24
- UseragentParser::UserAgent.new({ 'family' => 'Chrome', 'v1' => '14', 'v2' => '0', 'v3' => '835' }).browser_version.should == '14.0.835'
25
- end
26
-
27
- it "should report the browser version without patch level" do
28
- UseragentParser::UserAgent.new({ 'family' => 'Firefox', 'v1' => '5', 'v2' => '0' }).browser_version.should == '5.0'
29
- end
30
-
31
- it "should report the browser version without minor version" do
32
- UseragentParser::UserAgent.new({ 'family' => 'Firefox', 'v1' => '5' }).browser_version.should == '5'
33
- end
34
-
35
- it "should report the browser family without version" do
36
- UseragentParser::UserAgent.new({ 'family' => 'Opera' }).browser_version.should == ''
37
- end
38
- end
39
-
40
- describe "for operating system details" do
41
- it "should report the os family" do
42
- UseragentParser::UserAgent.new({ 'os_family' => 'Windows NT', 'os_v1' => '3', 'os_v2' => '1' }).os_family.should == 'Windows NT'
43
- end
44
-
45
- it "should report the major os version" do
46
- UseragentParser::UserAgent.new({ 'os_family' => 'Windows NT', 'os_v1' => '3', 'os_v2' => '1' }).os_major_version.should == '3'
47
- end
48
-
49
- it "should report the minor os version" do
50
- UseragentParser::UserAgent.new({ 'os_family' => 'Windows NT', 'os_v1' => '3', 'os_v2' => '1' }).os_minor_version.should == '1'
51
- end
52
-
53
- it "should report the os patchlevel" do
54
- UseragentParser::UserAgent.new({ 'os_family' => 'Windows NT', 'os_v1' => '3', 'os_v2' => '1' }).os_patch_version.should be_nil
55
- end
56
-
57
- it "should report the os version" do
58
- UseragentParser::UserAgent.new({ 'os_family' => 'Windows NT', 'os_v1' => '3', 'os_v2' => '1' }).os_version.should == '3.1'
59
- end
60
-
61
- it "should know the code name for Windows NT 3.1" do
62
- UseragentParser::UserAgent.new({ 'os_family' => 'Windows NT', 'os_v1' => '3', 'os_v2' => '1' }).os.should == 'Microsoft Windows NT 3.1'
63
- end
64
-
65
- it "should know the code name for Windows NT 3.5" do
66
- UseragentParser::UserAgent.new({ 'os_family' => 'Windows NT', 'os_v1' => '3', 'os_v2' => '5' }).os.should == 'Microsoft Windows NT 3.5'
67
- end
68
-
69
- it "should know the code name for Windows NT 4.0" do
70
- UseragentParser::UserAgent.new({ 'os_family' => 'Windows NT', 'os_v1' => '4', 'os_v2' => '0' }).os.should == 'Microsoft Windows NT 4.0'
71
- end
72
-
73
- it "should know the code name for Windows 2000" do
74
- UseragentParser::UserAgent.new({ 'os_family' => 'Windows NT', 'os_v1' => '5', 'os_v2' => '0' }).os.should == 'Microsoft Windows 2000'
75
- end
76
-
77
- it "should know the code name for Windows XP" do
78
- UseragentParser::UserAgent.new({ 'os_family' => 'Windows NT', 'os_v1' => '5', 'os_v2' => '1' }).os.should == 'Microsoft Windows XP'
79
- end
80
-
81
- it "should know the code name for Windows XP 64bit / Server 2003" do
82
- UseragentParser::UserAgent.new({ 'os_family' => 'Windows NT', 'os_v1' => '5', 'os_v2' => '2' }).os.should == 'Microsoft Windows XP 64bit / Server 2003'
83
- end
84
-
85
- it "should know the code name for Windows Vista / Server 2008" do
86
- UseragentParser::UserAgent.new({ 'os_family' => 'Windows NT', 'os_v1' => '6', 'os_v2' => '0' }).os.should == 'Microsoft Windows Vista / Server 2008'
87
- end
88
-
89
- it "should know the code name for Windows 7 / Server 2008 R2" do
90
- UseragentParser::UserAgent.new({ 'os_family' => 'Windows NT', 'os_v1' => '6', 'os_v2' => '1' }).os.should == 'Microsoft Windows 7 / Server 2008 R2'
91
- end
92
-
93
- it "should know the code name for Windows 8" do
94
- UseragentParser::UserAgent.new({ 'os_family' => 'Windows NT', 'os_v1' => '6', 'os_v2' => '2' }).os.should == 'Microsoft Windows 8'
95
- end
96
-
97
- it "should know the code name for Windows 3.1" do
98
- UseragentParser::UserAgent.new({ 'os_family' => 'Windows', 'os_v1' => '3', 'os_v2' => '1' }).os.should == 'Microsoft Windows 3.1'
99
- end
100
-
101
- it "should know the code name for Windows 95" do
102
- UseragentParser::UserAgent.new({ 'os_family' => 'Windows', 'os_v1' => '95' }).os.should == 'Microsoft Windows 95'
103
- end
104
-
105
- it "should know the code name for Windows 98" do
106
- UseragentParser::UserAgent.new({ 'os_family' => 'Windows', 'os_v1' => '98' }).os.should == 'Microsoft Windows 98'
107
- end
108
-
109
- it "should know the code name for Windows ME" do
110
- UseragentParser::UserAgent.new({ 'os_family' => 'Windows', 'os_v1' => 'ME' }).os.should == 'Microsoft Windows ME'
111
- end
112
-
113
- it "should know the code name for Windows 9x" do
114
- UseragentParser::UserAgent.new({ 'os_family' => 'Windows', 'os_v1' => '9x' }).os.should == 'Microsoft Windows 9x'
115
- end
116
-
117
- it "should know the code name for Mac OS X 10.0" do
118
- UseragentParser::UserAgent.new({ 'os_family' => 'Mac OS X', 'os_v1' => '10', 'os_v2' => '0' }).os.should == 'Apple Mac OS X 10.0 (Cheetah)'
119
- end
120
-
121
- it "should know the code name for Mac OS X 10.0" do
122
- UseragentParser::UserAgent.new({ 'os_family' => 'Mac OS X', 'os_v1' => '10', 'os_v2' => '0', 'os_v3' => 2 }).os.should == 'Apple Mac OS X 10.0.2 (Cheetah)'
123
- end
124
-
125
- it "should know the code name for Mac OS X 10.1" do
126
- UseragentParser::UserAgent.new({ 'os_family' => 'Mac OS X', 'os_v1' => '10', 'os_v2' => '1', 'os_v3' => 2 }).os.should == 'Apple Mac OS X 10.1.2 (Puma)'
127
- end
128
-
129
- it "should know the code name for Mac OS X 10.2" do
130
- UseragentParser::UserAgent.new({ 'os_family' => 'Mac OS X', 'os_v1' => '10', 'os_v2' => '2', 'os_v3' => 2 }).os.should == 'Apple Mac OS X 10.2.2 (Jaguar)'
131
- end
132
-
133
- it "should know the code name for Mac OS X 10.3" do
134
- UseragentParser::UserAgent.new({ 'os_family' => 'Mac OS X', 'os_v1' => '10', 'os_v2' => '3', 'os_v3' => 2 }).os.should == 'Apple Mac OS X 10.3.2 (Panther)'
135
- end
136
-
137
- it "should know the code name for Mac OS X 10.4" do
138
- UseragentParser::UserAgent.new({ 'os_family' => 'Mac OS X', 'os_v1' => '10', 'os_v2' => '4', 'os_v3' => 2 }).os.should == 'Apple Mac OS X 10.4.2 (Tiger)'
139
- end
140
-
141
- it "should know the code name for Mac OS X 10.5" do
142
- UseragentParser::UserAgent.new({ 'os_family' => 'Mac OS X', 'os_v1' => '10', 'os_v2' => '5', 'os_v3' => 2 }).os.should == 'Apple Mac OS X 10.5.2 (Leopard)'
143
- end
144
-
145
- it "should know the code name for Mac OS X 10.6" do
146
- UseragentParser::UserAgent.new({ 'os_family' => 'Mac OS X', 'os_v1' => '10', 'os_v2' => '6', 'os_v3' => 2 }).os.should == 'Apple Mac OS X 10.6.2 (Snow Leopard)'
147
- end
148
-
149
- it "should know the code name for Mac OS X 10.7" do
150
- UseragentParser::UserAgent.new({ 'os_family' => 'Mac OS X', 'os_v1' => '10', 'os_v2' => '7', 'os_v3' => '2' }).os.should == 'Apple Mac OS X 10.7.2 (Lion)'
151
- end
152
-
153
- it "should provide a generic os/version for other operating systems" do
154
- UseragentParser::UserAgent.new({ 'os_family' => 'Linux', 'os_v1' => '2', 'os_v2' => '6', 'os_v3' => '32' }).os.should == 'Linux 2.6.32'
155
- end
156
-
157
- it "should provide a generic os name without version" do
158
- UseragentParser::UserAgent.new({ 'os_family' => 'FreeBSD' }).os.should == 'FreeBSD'
159
- end
160
- end
161
-
162
- it "should confuse operating system and browser version" do
163
- ua = UseragentParser::UserAgent.new({ 'os_family' => 'Mac OS X', 'os_v1' => '10', 'os_v2' => '7', 'os_v3' => '2', 'family' => 'Chrome', 'v1' => '14', 'v2' => '0', 'v3' => '835' })
164
- ua.browser_family.should == 'Chrome'
165
- ua.browser_version.should == '14.0.835'
166
- ua.os_family.should == 'Mac OS X'
167
- ua.os_version.should == '10.7.2'
168
- end
169
- end