Module: Woothee
- Defined in:
- lib/woothee.rb,
lib/woothee/dataset.rb,
lib/woothee/version.rb
Defined Under Namespace
Modules: Appliance, Browser, Crawler, DataSet, Misc, MobilePhone, OS, Util
Constant Summary
collapse
- FILLED =
{
Woothee::ATTRIBUTE_NAME => Woothee::VALUE_UNKNOWN,
Woothee::ATTRIBUTE_CATEGORY => Woothee::VALUE_UNKNOWN,
Woothee::ATTRIBUTE_OS => Woothee::VALUE_UNKNOWN,
Woothee::ATTRIBUTE_OS_VERSION => Woothee::VALUE_UNKNOWN,
Woothee::ATTRIBUTE_VERSION => Woothee::VALUE_UNKNOWN,
Woothee::ATTRIBUTE_VENDOR => Woothee::VALUE_UNKNOWN,
}.freeze
- KEY_LABEL =
:label
- KEY_NAME =
:name
- KEY_TYPE =
:type
- KEY_CATEGORY =
:category
- KEY_OS =
:os
- KEY_OS_VERSION =
:os_version
- KEY_VENDOR =
:vendor
- KEY_VERSION =
:version
- TYPE_BROWSER =
:browser
- TYPE_OS =
:os
- TYPE_FULL =
:full
- CATEGORY_PC =
:pc
- CATEGORY_SMARTPHONE =
:smartphone
- CATEGORY_MOBILEPHONE =
:mobilephone
- CATEGORY_CRAWLER =
:crawler
- CATEGORY_APPLIANCE =
:appliance
- CATEGORY_MISC =
:misc
- ATTRIBUTE_NAME =
:name
- ATTRIBUTE_CATEGORY =
:category
- ATTRIBUTE_OS =
:os
- ATTRIBUTE_OS_VERSION =
:os_version
- ATTRIBUTE_VENDOR =
:vendor
- ATTRIBUTE_VERSION =
:version
- VALUE_UNKNOWN =
"UNKNOWN"
- CATEGORY_LIST =
[CATEGORY_PC,CATEGORY_SMARTPHONE,CATEGORY_MOBILEPHONE,CATEGORY_CRAWLER,CATEGORY_APPLIANCE,CATEGORY_MISC,VALUE_UNKNOWN]
- ATTRIBUTE_LIST =
[ATTRIBUTE_NAME,ATTRIBUTE_CATEGORY,ATTRIBUTE_OS,ATTRIBUTE_VENDOR,ATTRIBUTE_VERSION,ATTRIBUTE_OS_VERSION]
- VERSION =
"1.13.0"
Class Method Summary
collapse
Class Method Details
.exec_parse(useragent) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/woothee.rb', line 22
def self.exec_parse(useragent)
result = {}
return result if useragent.nil? or useragent.length < 1 or useragent == '-'
if try_crawler(useragent, result)
return result
end
if try_browser(useragent, result)
if try_os(useragent, result)
return result
else
return result
end
end
if try_mobilephone(useragent, result)
return result
end
if try_appliance(useragent, result)
return result
end
if try_misc(useragent, result)
return result
end
if try_os(useragent, result)
return result
end
if try_rare_cases(useragent, result)
return result
end
result
end
|
.fill_result(result) ⇒ Object
167
168
169
|
# File 'lib/woothee.rb', line 167
def self.fill_result(result)
FILLED.merge(result)
end
|
.is_crawler(useragent) ⇒ Object
18
19
20
|
# File 'lib/woothee.rb', line 18
def self.is_crawler(useragent)
!!useragent && useragent.length > 0 and useragent != '-' and try_crawler(useragent, {})
end
|
.parse(useragent) ⇒ Object
14
15
16
|
# File 'lib/woothee.rb', line 14
def self.parse(useragent)
fill_result(exec_parse(useragent))
end
|
.try_appliance(useragent, result) ⇒ Object
.try_browser(useragent, result) ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/woothee.rb', line 71
def self.try_browser(useragent, result)
return true if Woothee::Browser.challenge_msie(useragent, result)
return true if Woothee::Browser.challenge_vivaldi(useragent, result)
return true if Woothee::Browser.challenge_yandexbrowser(useragent, result)
return true if Woothee::Browser.challenge_samsungbrowser(useragent, result)
return true if Woothee::Browser.challenge_safari_chrome(useragent, result)
return true if Woothee::Browser.challenge_firefox(useragent, result)
return true if Woothee::Browser.challenge_opera(useragent, result)
return true if Woothee::Browser.challenge_webview(useragent, result)
false
end
|
.try_crawler(useragent, result) ⇒ Object
.try_misc(useragent, result) ⇒ Object
139
140
141
142
143
|
# File 'lib/woothee.rb', line 139
def self.try_misc(useragent, result)
return true if Woothee::Misc.challenge_desktoptools(useragent, result)
false
end
|
.try_mobilephone(useragent, result) ⇒ Object
.try_os(useragent, result) ⇒ Object
.try_rare_cases(useragent, result) ⇒ Object