useragent 0.4.11 → 0.4.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/user_agent/browsers/all.rb +9 -4
- metadata +1 -1
@@ -29,11 +29,11 @@ class UserAgent
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def browser
|
32
|
-
application.product
|
32
|
+
application && application.product
|
33
33
|
end
|
34
34
|
|
35
35
|
def version
|
36
|
-
application.version
|
36
|
+
application && application.version
|
37
37
|
end
|
38
38
|
|
39
39
|
def platform
|
@@ -63,7 +63,7 @@ class UserAgent
|
|
63
63
|
true
|
64
64
|
elsif detect_product('Mobile')
|
65
65
|
true
|
66
|
-
elsif application.comment &&
|
66
|
+
elsif application && application.comment &&
|
67
67
|
application.comment.detect { |k, v| k =~ /^IEMobile/ }
|
68
68
|
true
|
69
69
|
else
|
@@ -72,6 +72,11 @@ class UserAgent
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def bot?
|
75
|
+
# If UA has no application type, its probably generated by a
|
76
|
+
# shitty bot.
|
77
|
+
if application.nil?
|
78
|
+
true
|
79
|
+
|
75
80
|
# Match common case when bots refer to themselves as bots in
|
76
81
|
# the application comment. There are no standards for how bots
|
77
82
|
# should call themselves so its not an exhaustive method.
|
@@ -79,7 +84,7 @@ class UserAgent
|
|
79
84
|
# If you want to expand the scope, override the method and
|
80
85
|
# provide your own regexp. Any patches to future extend this
|
81
86
|
# list will be rejected.
|
82
|
-
|
87
|
+
elsif comment = application.comment
|
83
88
|
comment.any? { |c| c =~ /bot/i }
|
84
89
|
else
|
85
90
|
false
|