aua 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/.rvmrc +1 -0
- data/CHANGES.md +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +42 -0
- data/Guardfile +5 -0
- data/LICENSE +20 -0
- data/README.md +22 -0
- data/Rakefile +7 -0
- data/aua.gemspec +26 -0
- data/lib/aua.rb +87 -0
- data/lib/aua/agents.rb +16 -0
- data/lib/aua/agents/api_clients.rb +42 -0
- data/lib/aua/agents/chrome.rb +35 -0
- data/lib/aua/agents/engine_fallback.rb +19 -0
- data/lib/aua/agents/feed_reader.rb +19 -0
- data/lib/aua/agents/firefox.rb +40 -0
- data/lib/aua/agents/http_checker.rb +28 -0
- data/lib/aua/agents/konqueror.rb +20 -0
- data/lib/aua/agents/msie.rb +23 -0
- data/lib/aua/agents/opera.rb +28 -0
- data/lib/aua/agents/others.rb +33 -0
- data/lib/aua/agents/safari.rb +66 -0
- data/lib/aua/agents/search_bot.rb +36 -0
- data/lib/aua/operating_systems.rb +16 -0
- data/lib/aua/operating_systems/android.rb +28 -0
- data/lib/aua/operating_systems/ios.rb +20 -0
- data/lib/aua/operating_systems/linux.rb +42 -0
- data/lib/aua/operating_systems/mac.rb +74 -0
- data/lib/aua/operating_systems/mobiles.rb +35 -0
- data/lib/aua/operating_systems/palm.rb +33 -0
- data/lib/aua/operating_systems/windows.rb +36 -0
- data/lib/aua/stack_base.rb +10 -0
- data/lib/aua/version.rb +3 -0
- data/spec/aua_spec.rb +474 -0
- data/spec/spec_helper.rb +8 -0
- metadata +160 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
module Aua::Agents::Konqueror
|
2
|
+
def self.extend?(agent)
|
3
|
+
agent.products.include?("KHTML") &&
|
4
|
+
agent.app_comments[1] =~ PATTERN
|
5
|
+
end
|
6
|
+
|
7
|
+
PATTERN = /Konqueror\/([\d\.]+)/
|
8
|
+
|
9
|
+
def type
|
10
|
+
:Browser
|
11
|
+
end
|
12
|
+
|
13
|
+
def name
|
14
|
+
@name ||= :Konqueror
|
15
|
+
end
|
16
|
+
|
17
|
+
def version
|
18
|
+
@version ||= app_comments[1] =~ PATTERN && $1
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Aua::Agents::Msie
|
2
|
+
|
3
|
+
def self.extend?(agent)
|
4
|
+
agent.app_comments_string =~ PATTERN
|
5
|
+
end
|
6
|
+
|
7
|
+
PATTERN = /MSIE ([\d.]+)/
|
8
|
+
|
9
|
+
def type
|
10
|
+
:Browser
|
11
|
+
end
|
12
|
+
|
13
|
+
def name
|
14
|
+
:MSIE
|
15
|
+
end
|
16
|
+
|
17
|
+
def version
|
18
|
+
@version ||= begin
|
19
|
+
app_comments_string =~ PATTERN
|
20
|
+
$1
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Aua::Agents::Opera
|
2
|
+
def self.extend?(agent)
|
3
|
+
agent.products.include?("Opera")
|
4
|
+
end
|
5
|
+
|
6
|
+
PATTERN = /Opera ([\d.]+)/
|
7
|
+
PATTERN_MINI = /Opera Mini\/([\d.]+)/
|
8
|
+
PATTERN_MOBILE = /Opera Mobi\//
|
9
|
+
|
10
|
+
def type
|
11
|
+
:Browser
|
12
|
+
end
|
13
|
+
|
14
|
+
def name
|
15
|
+
@name ||= begin
|
16
|
+
return :OperaMobile if app_comments_string =~ PATTERN_MOBILE
|
17
|
+
return :OperaMini if app_comments_string =~ PATTERN_MINI
|
18
|
+
:Opera
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def version
|
23
|
+
@version ||= begin
|
24
|
+
return $1 if app_comments[1] =~ PATTERN_MINI
|
25
|
+
(raw =~ PATTERN && $1) || version_of("Version") || version_of("Opera")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Aua::Agents::Others
|
2
|
+
KNOWN_CLIENTS = %w(1PasswordThumbs)
|
3
|
+
|
4
|
+
def self.extend?(agent)
|
5
|
+
KNOWN_CLIENTS.include?(agent.app) ||
|
6
|
+
(agent.app == "Microsoft" && agent.products[1] == "Office") ||
|
7
|
+
agent.products[-1] == "Word"
|
8
|
+
end
|
9
|
+
|
10
|
+
def type
|
11
|
+
:Others
|
12
|
+
end
|
13
|
+
|
14
|
+
def name
|
15
|
+
@name ||= begin
|
16
|
+
if app == "Microsoft" && products[1] == "Office"
|
17
|
+
:MSOffice
|
18
|
+
elsif products[-1] == "Word"
|
19
|
+
:MSWord
|
20
|
+
else
|
21
|
+
app.to_sym
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def version
|
27
|
+
@version ||= begin
|
28
|
+
return version_of("Word") if name == :MSWord
|
29
|
+
return version_of("Office") if name == :MSOffice
|
30
|
+
super
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module Aua::Agents::Safari
|
2
|
+
def self.extend?(agent)
|
3
|
+
agent.products[-1] == "Safari" ||
|
4
|
+
agent.products[0] == "Safari" ||
|
5
|
+
(agent.products == ["Mozilla", "AppleWebKit", "Mobile"] && Aua::OperatingSystems::IOS::PLATFORMS.include?(agent.platform_string)) ||
|
6
|
+
agent.products.include?("OmniWeb") ||
|
7
|
+
agent.products[0] == "MobileSafari"
|
8
|
+
end
|
9
|
+
|
10
|
+
BUILDS = {
|
11
|
+
'85' => '1.0',
|
12
|
+
'85.5'=>'1.0',
|
13
|
+
'85.7'=>'1.0.2',
|
14
|
+
'85.8'=>'1.0.3',
|
15
|
+
'85.8.1'=>'1.0.3',
|
16
|
+
'100'=>'1.1',
|
17
|
+
'100.1'=>'1.1.1',
|
18
|
+
'125.7'=>'1.2.2',
|
19
|
+
'125.8'=>'1.2.2',
|
20
|
+
'125.9'=>'1.2.3',
|
21
|
+
'125.11'=>'1.2.4',
|
22
|
+
'125.12'=>'1.2.4',
|
23
|
+
'312'=>'1.3',
|
24
|
+
'312.3'=>'1.3.1',
|
25
|
+
'312.3.1'=>'1.3.1',
|
26
|
+
'312.5'=>'1.3.2',
|
27
|
+
'312.6'=>'1.3.2',
|
28
|
+
'412'=>'2.0',
|
29
|
+
'412.2'=>'2.0',
|
30
|
+
'412.2.2'=>'2.0',
|
31
|
+
'412.5'=>'2.0.1',
|
32
|
+
'416.12'=>'2.0.2',
|
33
|
+
'416.13'=>'2.0.2',
|
34
|
+
'417.8'=>'2.0.3',
|
35
|
+
'417.9.2'=>'2.0.3',
|
36
|
+
'417.9.3'=>'2.0.3',
|
37
|
+
'419.3'=>'2.0.4',
|
38
|
+
'419' => '2.0.4',
|
39
|
+
'425.13' => '2.2'
|
40
|
+
}
|
41
|
+
|
42
|
+
def type
|
43
|
+
:Browser
|
44
|
+
end
|
45
|
+
|
46
|
+
def name
|
47
|
+
@name ||= begin
|
48
|
+
return :MobileSafari if products.include?("Mobile") || products[0] == "MobileSafari"
|
49
|
+
return :Fluid if products.include?("Fluid")
|
50
|
+
return :OmniWeb if products.include?("OmniWeb")
|
51
|
+
:Safari
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def version
|
56
|
+
@version ||= begin
|
57
|
+
case name
|
58
|
+
when :Fluid, :OmniWeb
|
59
|
+
version_of(name)
|
60
|
+
else
|
61
|
+
version_of("Version") || BUILDS[version_of("Safari")] ||
|
62
|
+
version_of("Mobile") || version_of("MobileSafari") || version_of("Safari")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Aua::Agents::SearchBot
|
2
|
+
PATTERN_BING = /bingbot\/([\d\.]+)/
|
3
|
+
PATTERN_BAIDU = /Baiduspider\/?([\d\.]+)?/
|
4
|
+
PATTERN_GOOGLE = /Googlebot(-Mobile)?\/?([\d\.]+)?/
|
5
|
+
|
6
|
+
def self.extend?(agent)
|
7
|
+
agent.raw =~ PATTERN_BING ||
|
8
|
+
agent.app_comments[1] == "Yahoo! Slurp" ||
|
9
|
+
agent.raw =~ PATTERN_BAIDU ||
|
10
|
+
agent.raw =~ PATTERN_GOOGLE ||
|
11
|
+
agent.app == "msnbot"
|
12
|
+
end
|
13
|
+
|
14
|
+
def type
|
15
|
+
:SearchBot
|
16
|
+
end
|
17
|
+
|
18
|
+
def name
|
19
|
+
@name ||= begin
|
20
|
+
return :Bingbot if raw =~ PATTERN_BING
|
21
|
+
return :YahooSlurp if app_comments[1] == "Yahoo! Slurp"
|
22
|
+
return :Baiduspider if raw =~ PATTERN_BAIDU
|
23
|
+
return $1 ? :GooglebotMobile : :Googlebot if raw =~ PATTERN_GOOGLE
|
24
|
+
app.to_sym
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def version
|
29
|
+
@version ||= begin
|
30
|
+
return $1 if raw =~ PATTERN_BING
|
31
|
+
return $1 if raw =~ PATTERN_BAIDU
|
32
|
+
return $2 if raw =~ PATTERN_GOOGLE
|
33
|
+
super
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'aua/stack_base'
|
2
|
+
|
3
|
+
class Aua
|
4
|
+
module OperatingSystems
|
5
|
+
extend StackBase
|
6
|
+
extend self
|
7
|
+
|
8
|
+
def default
|
9
|
+
[Mobiles, Windows, Mac, Android, Linux, IOS, Palm]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
Dir["#{File.dirname(__FILE__)}/operating_systems/*.rb"].each do |os|
|
15
|
+
require(os)
|
16
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Aua::OperatingSystems::Android
|
2
|
+
|
3
|
+
def self.extend?(agent)
|
4
|
+
agent.platform_string == "Linux" && agent.comments.first && agent.comments.first[2] && agent.comments.first[2].match(PATTERN)
|
5
|
+
end
|
6
|
+
|
7
|
+
PATTERN = /^Android\s([\d\.]+)$/
|
8
|
+
|
9
|
+
def platform
|
10
|
+
@platform ||= :Android
|
11
|
+
end
|
12
|
+
|
13
|
+
def os_name
|
14
|
+
@os_name ||= :Android
|
15
|
+
end
|
16
|
+
|
17
|
+
def os_version
|
18
|
+
@os_version ||= comments.first[2] =~ PATTERN && $1
|
19
|
+
end
|
20
|
+
|
21
|
+
def name
|
22
|
+
@name ||= :AndroidWebkit
|
23
|
+
end
|
24
|
+
|
25
|
+
def version
|
26
|
+
@version ||= version_of("Version")
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Aua::OperatingSystems::IOS
|
2
|
+
PLATFORMS = %w(iPhone iPad iPod)
|
3
|
+
PATTERN = /CPU( iPhone)?( OS )?([\d\._]+)? like Mac OS X/
|
4
|
+
|
5
|
+
def self.extend?(agent)
|
6
|
+
PLATFORMS.include?(agent.platform_string) && agent.os_string =~ PATTERN
|
7
|
+
end
|
8
|
+
|
9
|
+
def platform
|
10
|
+
platform_string.to_sym
|
11
|
+
end
|
12
|
+
|
13
|
+
def os_name
|
14
|
+
:iOS
|
15
|
+
end
|
16
|
+
|
17
|
+
def os_version
|
18
|
+
os_string =~ PATTERN && $3 && $3.gsub(/_/, ".")
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Aua::OperatingSystems::Linux
|
2
|
+
|
3
|
+
def self.extend?(agent)
|
4
|
+
agent.platform_string == "X11" || agent.app_comments_string.match(PATTERN_LINUX)
|
5
|
+
end
|
6
|
+
|
7
|
+
PATTERN_LINUX = /(l|L)inux/
|
8
|
+
|
9
|
+
def platform
|
10
|
+
:X11
|
11
|
+
end
|
12
|
+
|
13
|
+
def os_name
|
14
|
+
:Linux
|
15
|
+
end
|
16
|
+
|
17
|
+
def os_version
|
18
|
+
@os_version ||= if app_comments_string =~ /OpenBSD/
|
19
|
+
"OpenBSD"
|
20
|
+
elsif products.include?("Ubuntu")
|
21
|
+
"Ubuntu"
|
22
|
+
elsif products.include?("Red") && products.include?("Hat")
|
23
|
+
"Red Hat"
|
24
|
+
elsif products.include?("CentOS")
|
25
|
+
"CentOS"
|
26
|
+
elsif products.include?("Gentoo")
|
27
|
+
"Gentoo"
|
28
|
+
elsif products.include?("SUSE")
|
29
|
+
"SUSE"
|
30
|
+
elsif products.include?("Fedora")
|
31
|
+
"Fedora"
|
32
|
+
elsif app_comments_string =~ /FreeBSD/
|
33
|
+
"FreeBSD"
|
34
|
+
elsif raw =~ /SunOS/
|
35
|
+
"Solaris"
|
36
|
+
elsif raw =~ /Debian/
|
37
|
+
"Debian"
|
38
|
+
elsif raw =~ /Maemo/
|
39
|
+
"Maemo"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module Aua::OperatingSystems::Mac
|
2
|
+
|
3
|
+
def self.extend?(agent)
|
4
|
+
agent.platform_string == "Macintosh" ||
|
5
|
+
agent.os_string && agent.os_string =~ PATTERN_MACOS ||
|
6
|
+
agent.products.include?("Darwin")
|
7
|
+
end
|
8
|
+
|
9
|
+
PATTERN_OSX = /Mac OS X\s?([\d\._]+)?/
|
10
|
+
PATTERN_MACOS = /Mac_PowerPC/
|
11
|
+
DAWRWIN_2_OSX = {
|
12
|
+
'1.0.2' => 'DP2',
|
13
|
+
'1.1' => 'DP4',
|
14
|
+
'1.2.1' => 'Public Beta',
|
15
|
+
'1.3.1' => '10.0',
|
16
|
+
'1.4.1' => '10.1',
|
17
|
+
'6.0.1' => '10.2',
|
18
|
+
'6.0.2' => '10.2',
|
19
|
+
'7.0' => '10.3',
|
20
|
+
'8.0' => '10.4',
|
21
|
+
'9.0' => '10.5',
|
22
|
+
'9.1.0' => '10.5.1',
|
23
|
+
'9.2.0' => '10.5.2',
|
24
|
+
'9.3.0' => '10.5.3',
|
25
|
+
'9.4.0' => '10.5.4',
|
26
|
+
'9.5.0' => '10.5.5',
|
27
|
+
'9.6.0' => '10.5.6',
|
28
|
+
'9.7.0' => '10.5.7',
|
29
|
+
'9.8.0' => '10.5.8',
|
30
|
+
'10.0' => '10.6',
|
31
|
+
'10.1.0' => '10.6.1',
|
32
|
+
'10.2.0' => '10.6.2',
|
33
|
+
'10.3.0' => '10.6.3',
|
34
|
+
'10.4.0' => '10.6.4',
|
35
|
+
'10.5.0' => '10.6.5',
|
36
|
+
'10.6.0' => '10.6.6'
|
37
|
+
}
|
38
|
+
|
39
|
+
def platform
|
40
|
+
darwin? && !DAWRWIN_2_OSX[version_of(:Darwin)] ? :Darwin : :Macintosh
|
41
|
+
end
|
42
|
+
|
43
|
+
def os_name
|
44
|
+
@os_name ||= if osx?
|
45
|
+
:MacOSX
|
46
|
+
elsif darwin?
|
47
|
+
DAWRWIN_2_OSX[version_of(:Darwin)] ? :MacOSX : :Darwin
|
48
|
+
elsif macos?
|
49
|
+
:MacOS
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def os_version
|
54
|
+
@os_version ||= if m = osx?
|
55
|
+
m[1] ? m[1].gsub(/_/, ".") : nil
|
56
|
+
elsif darwin?
|
57
|
+
DAWRWIN_2_OSX[version_of(:Darwin)] || version_of(:Darwin)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def osx?
|
64
|
+
app_comments_string.match PATTERN_OSX
|
65
|
+
end
|
66
|
+
|
67
|
+
def macos?
|
68
|
+
app_comments_string.match PATTERN_MACOS
|
69
|
+
end
|
70
|
+
|
71
|
+
def darwin?
|
72
|
+
products.include?("Darwin")
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Aua::OperatingSystems::Mobiles
|
2
|
+
def self.extend?(agent)
|
3
|
+
agent.platform_string == "BlackBerry" ||
|
4
|
+
agent.platform_string == "J2ME/MIDP" ||
|
5
|
+
agent.app_comments_string =~ PATTERN_SYMBIAN
|
6
|
+
end
|
7
|
+
|
8
|
+
PATTERN_SYMBIAN = /Symb(ian)?\s?OS\/?([\d\.]+)?/
|
9
|
+
|
10
|
+
def name
|
11
|
+
@name ||= begin
|
12
|
+
name = super
|
13
|
+
return :OperaMobile if name == :Opera && platform == :SymbianOS
|
14
|
+
name
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def platform
|
19
|
+
@platform ||= begin
|
20
|
+
return :SymbianOS if app_comments_string =~ PATTERN_SYMBIAN
|
21
|
+
platform_string.to_sym
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def os_name
|
26
|
+
@os_name ||= platform
|
27
|
+
end
|
28
|
+
|
29
|
+
def os_version
|
30
|
+
@os_version ||= begin
|
31
|
+
return $2 if app_comments_string =~ PATTERN_SYMBIAN
|
32
|
+
nil
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Aua::OperatingSystems::Palm
|
2
|
+
#{ }"Mozilla/5.0 (webOS/1.3; U; en-US) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/1.0 Safari/525.27.1 Desktop/1.0"
|
3
|
+
|
4
|
+
def self.extend?(agent)
|
5
|
+
agent.platform_string =~ PATTERN && agent.products.include?("Safari")
|
6
|
+
end
|
7
|
+
|
8
|
+
PATTERN = /^webOS\/([\d\.]+)$/
|
9
|
+
|
10
|
+
def platform
|
11
|
+
@platform ||= :webOS
|
12
|
+
end
|
13
|
+
|
14
|
+
def os_name
|
15
|
+
@os_name ||= :webOS
|
16
|
+
end
|
17
|
+
|
18
|
+
def os_version
|
19
|
+
@os_version ||= platform_string =~ PATTERN && $1
|
20
|
+
end
|
21
|
+
|
22
|
+
def type
|
23
|
+
:Browser
|
24
|
+
end
|
25
|
+
|
26
|
+
def name
|
27
|
+
@name ||= :webOSWebkit
|
28
|
+
end
|
29
|
+
|
30
|
+
def version
|
31
|
+
@version ||= version_of("Version")
|
32
|
+
end
|
33
|
+
end
|