Module: Woothee::OS
- Extended by:
- Util
- Defined in:
- lib/woothee/os.rb
Class Method Summary
collapse
Methods included from Util
update_category, update_map, update_os, update_os_version, update_version
Class Method Details
.challenge_appliance(ua, result) ⇒ Object
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
# File 'lib/woothee/os.rb', line 193
def self.challenge_appliance(ua, result)
if ua.index('Nintendo DSi;')
data = Woothee::DataSet.get('NintendoDSi')
update_category(result, data[Woothee::KEY_CATEGORY])
update_os(result, data[Woothee::KEY_OS])
return true
end
if ua.index('Nintendo Wii;')
data = Woothee::DataSet.get('NintendoWii')
update_category(result, data[Woothee::KEY_CATEGORY])
update_os(result, data[Woothee::KEY_OS])
return true
end
false
end
|
.challenge_linux(ua, result) ⇒ Object
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/woothee/os.rb', line 85
def self.challenge_linux(ua, result)
data = nil
os_version = nil
if ua.index('Android')
data = Woothee::DataSet.get('Android')
if ua =~ /Android[- ](\d+(?:\.\d+(?:\.\d+)?)?)/
os_version = $1
end
elsif ua.index('Linux')
data = Woothee::DataSet.get('Linux')
else
return false
end
update_category(result, data[Woothee::KEY_CATEGORY])
update_os(result, data[Woothee::KEY_NAME])
if os_version
update_os_version(result, os_version)
end
true
end
|
.challenge_misc(ua, result) ⇒ Object
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
|
# File 'lib/woothee/os.rb', line 210
def self.challenge_misc(ua, result)
data = nil
os_version = nil
case
when ua.index('(Win98;')
data = Woothee::DataSet.get('Win98')
os_version = "98"
when ua.index('Macintosh; U; PPC;')
data = Woothee::DataSet.get('MacOS')
if ua =~ /rv:(\d+\.\d+\.\d+)/
os_version = $1
end
when ua.index('Mac_PowerPC')
data = Woothee::DataSet.get('MacOS')
when ua.index('X11; FreeBSD ')
data = Woothee::DataSet.get('BSD')
if ua =~ /FreeBSD ([^;\)]+);/
os_version = $1
end
when ua.index('X11; CrOS ')
data = Woothee::DataSet.get('ChromeOS')
if ua =~ /CrOS ([^\)]+)\)/
os_version = $1
end
else
nil
end
if data
update_category(result, data[Woothee::KEY_CATEGORY])
update_os(result, data[Woothee::KEY_NAME])
if os_version
update_os_version(result, os_version)
end
return true
end
false
end
|
.challenge_mobilephone(ua, result) ⇒ Object
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
# File 'lib/woothee/os.rb', line 152
def self.challenge_mobilephone(ua, result)
if ua.index('KDDI-')
if ua =~ /KDDI-([^- \/;()"']+)/o
term = $1
data = Woothee::DataSet.get('au')
update_category(result, data[Woothee::KEY_CATEGORY])
update_os(result, data[Woothee::KEY_OS])
update_version(result, term)
return true
end
end
if ua.index('WILLCOM') or ua.index('DDIPOCKET')
if ua =~ /(?:WILLCOM|DDIPOCKET);[^\/]+\/([^ \/;()]+)/o
term = $1
data = Woothee::DataSet.get('willcom')
update_category(result, data[Woothee::KEY_CATEGORY])
update_os(result, data[Woothee::KEY_OS])
update_version(result, term)
return true
end
end
if ua.index('SymbianOS')
data = Woothee::DataSet.get('SymbianOS')
update_category(result, data[Woothee::KEY_CATEGORY])
update_os(result, data[Woothee::KEY_OS])
return true
end
if ua.index('Google Wireless Transcoder')
update_map(result, Woothee::DataSet.get('MobileTranscoder'))
update_version(result, 'Google')
return true
end
if ua.index('Naver Transcoder')
update_map(result, Woothee::DataSet.get('MobileTranscoder'))
update_version(result, 'Naver')
return true
end
false
end
|
.challenge_osx(ua, result) ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/woothee/os.rb', line 57
def self.challenge_osx(ua, result)
return false if ua.index('Mac OS X').nil?
data = Woothee::DataSet.get('OSX')
version = nil
if ua.index('like Mac OS X')
data = case
when ua.index('iPhone;') then Woothee::DataSet.get('iPhone')
when ua.index('iPad;') then Woothee::DataSet.get('iPad')
when ua.index('iPod') then Woothee::DataSet.get('iPod')
else data
end
if ua =~ /; CPU(?: iPhone)? OS (\d+_\d+(?:_\d+)?) like Mac OS X/
version = $1.gsub(/_/, '.')
end
else
if ua =~ /Mac OS X (10[._]\d+(?:[._]\d+)?)(?:\)|;)/
version = $1.gsub(/_/, '.')
end
end
update_category(result, data[Woothee::KEY_CATEGORY])
update_os(result, data[Woothee::KEY_NAME])
if version
update_os_version(result, version)
end
true
end
|
.challenge_smartphone(ua, result) ⇒ Object
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
# File 'lib/woothee/os.rb', line 106
def self.challenge_smartphone(ua, result)
data = nil
os_version = nil
case
when ua.index('iPhone')
data = Woothee::DataSet.get('iPhone')
when ua.index('iPad')
data = Woothee::DataSet.get('iPad')
when ua.index('iPod')
data = Woothee::DataSet.get('iPod')
when ua.index('Android')
data = Woothee::DataSet.get('Android')
when ua.index('CFNetwork')
data = Woothee::DataSet.get('iOS')
when ua.index('BB10')
data = Woothee::DataSet.get('BlackBerry10')
if ua =~ /BB10(?:.+)Version\/([.0-9]+)/
os_version = $1
end
when ua.index('BlackBerry')
data = Woothee::DataSet.get('BlackBerry')
if ua =~ /BlackBerry(?:\d+)\/([.0-9]+) /
os_version = $1
end
end
if result[Woothee::KEY_NAME] && result[Woothee::KEY_NAME] == Woothee::DataSet.get('Firefox')[Woothee::KEY_NAME]
if ua =~ /^Mozilla\/[.0-9]+ \((?:Mobile|Tablet);(?:.*;)? rv:([.0-9]+)\) Gecko\/[.0-9]+ Firefox\/[.0-9]+$/
data = Woothee::DataSet.get('FirefoxOS')
os_version = $1
end
end
return false unless data
update_category(result, data[Woothee::KEY_CATEGORY])
update_os(result, data[Woothee::KEY_NAME])
if os_version
update_os_version(result, os_version)
end
true
end
|
.challenge_windows(ua, result) ⇒ Object