useragent 0.4.11 → 0.4.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/user_agent/browsers/all.rb +9 -4
  2. 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
- if comment = application.comment
87
+ elsif comment = application.comment
83
88
  comment.any? { |c| c =~ /bot/i }
84
89
  else
85
90
  false
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: useragent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.11
4
+ version: 0.4.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: