aua 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,16 +1,16 @@
1
1
  module Aua::Agents::Others
2
2
  KNOWN_CLIENTS = %w(1PasswordThumbs 1PasswordThumbs1)
3
-
3
+
4
4
  def self.extend?(agent)
5
5
  KNOWN_CLIENTS.include?(agent.app) ||
6
6
  (agent.app == "Microsoft" && agent.products[1] == "Office") ||
7
7
  agent.products[-1] == "Word"
8
8
  end
9
-
9
+
10
10
  def type
11
11
  :Others
12
12
  end
13
-
13
+
14
14
  def name
15
15
  @name ||= begin
16
16
  if app == "Microsoft" && products[1] == "Office"
@@ -24,13 +24,13 @@ module Aua::Agents::Others
24
24
  end
25
25
  end
26
26
  end
27
-
27
+
28
28
  def version
29
29
  @version ||= begin
30
30
  return version_of("Word") if name == :MSWord
31
31
  return version_of("Office") if name == :MSOffice
32
32
  return "1" if app == "1PasswordThumbs1"
33
- super
33
+ super
34
34
  end
35
35
  end
36
36
  end
@@ -1,12 +1,12 @@
1
1
  module Aua::Agents::Safari
2
2
  def self.extend?(agent)
3
- agent.products[-1] == "Safari" ||
4
- agent.products[0] == "Safari" ||
3
+ agent.products[-1] == "Safari" ||
4
+ agent.products[0] == "Safari" ||
5
5
  (agent.products == ["Mozilla", "AppleWebKit", "Mobile"] && Aua::OperatingSystems::IOS::PLATFORMS.include?(agent.platform_string)) ||
6
6
  agent.products.include?("OmniWeb") ||
7
7
  agent.products[0] == "MobileSafari"
8
8
  end
9
-
9
+
10
10
  BUILDS = {
11
11
  '85' => '1.0',
12
12
  '85.5'=>'1.0',
@@ -38,11 +38,11 @@ module Aua::Agents::Safari
38
38
  '419' => '2.0.4',
39
39
  '425.13' => '2.2'
40
40
  }
41
-
41
+
42
42
  def type
43
43
  :Browser
44
44
  end
45
-
45
+
46
46
  def name
47
47
  @name ||= begin
48
48
  return :MobileSafari if products.include?("Mobile") || products[0] == "MobileSafari"
@@ -51,15 +51,15 @@ module Aua::Agents::Safari
51
51
  :Safari
52
52
  end
53
53
  end
54
-
54
+
55
55
  def version
56
56
  @version ||= begin
57
57
  case name
58
58
  when :Fluid, :OmniWeb
59
59
  version_of(name)
60
60
  else
61
- version_of("Version") || BUILDS[version_of("Safari")] ||
62
- version_of("Mobile") || version_of("MobileSafari") || version_of("Safari")
61
+ version_of("Version") || BUILDS[version_of("Safari")] ||
62
+ version_of("Mobile") || version_of("MobileSafari") || version_of("Safari")
63
63
  end
64
64
  end
65
65
  end
@@ -2,7 +2,7 @@ module Aua::Agents::SearchBot
2
2
  PATTERN_BING = /bingbot\/([\d\.]+)/
3
3
  PATTERN_BAIDU = /Baiduspider\/?([\d\.]+)?/
4
4
  PATTERN_GOOGLE = /Googlebot(-Mobile)?\/?([\d\.]+)?/
5
-
5
+
6
6
  def self.extend?(agent)
7
7
  agent.raw =~ PATTERN_BING ||
8
8
  agent.app_comments[1] == "Yahoo! Slurp" ||
@@ -10,11 +10,11 @@ module Aua::Agents::SearchBot
10
10
  agent.raw =~ PATTERN_GOOGLE ||
11
11
  agent.app == "msnbot"
12
12
  end
13
-
13
+
14
14
  def type
15
15
  :SearchBot
16
16
  end
17
-
17
+
18
18
  def name
19
19
  @name ||= begin
20
20
  return :Bingbot if raw =~ PATTERN_BING
@@ -24,13 +24,13 @@ module Aua::Agents::SearchBot
24
24
  app.to_sym
25
25
  end
26
26
  end
27
-
27
+
28
28
  def version
29
29
  @version ||= begin
30
30
  return $1 if raw =~ PATTERN_BING
31
31
  return $1 if raw =~ PATTERN_BAIDU
32
32
  return $2 if raw =~ PATTERN_GOOGLE
33
- super
33
+ super
34
34
  end
35
35
  end
36
36
  end
@@ -4,7 +4,7 @@ class Aua
4
4
  module OperatingSystems
5
5
  extend StackBase
6
6
  extend self
7
-
7
+
8
8
  def default
9
9
  [Mobiles, Windows, Mac, Android, Linux, IOS, Palm]
10
10
  end
@@ -1,28 +1,28 @@
1
1
  module Aua::OperatingSystems::Android
2
-
2
+
3
3
  def self.extend?(agent)
4
4
  agent.platform_string == "Linux" && agent.comments.first && agent.comments.first[2] && agent.comments.first[2].match(PATTERN)
5
5
  end
6
-
6
+
7
7
  PATTERN = /^Android\s([\d\.]+)$/
8
-
8
+
9
9
  def platform
10
10
  @platform ||= :Android
11
11
  end
12
-
12
+
13
13
  def os_name
14
14
  @os_name ||= :Android
15
15
  end
16
-
16
+
17
17
  def os_version
18
18
  @os_version ||= comments.first[2] =~ PATTERN && $1
19
19
  end
20
-
20
+
21
21
  def name
22
22
  @name ||= :AndroidWebkit
23
23
  end
24
-
24
+
25
25
  def version
26
- @version ||= version_of("Version")
26
+ @version ||= version_of("Version")
27
27
  end
28
28
  end
@@ -1,19 +1,19 @@
1
1
  module Aua::OperatingSystems::IOS
2
2
  PLATFORMS = %w(iPhone iPad iPod)
3
3
  PATTERN = /CPU( iPhone)?( OS )?([\d\._]+)? like Mac OS X/
4
-
4
+
5
5
  def self.extend?(agent)
6
6
  PLATFORMS.include?(agent.platform_string) && agent.os_string =~ PATTERN
7
7
  end
8
-
8
+
9
9
  def platform
10
10
  platform_string.to_sym
11
11
  end
12
-
12
+
13
13
  def os_name
14
14
  :iOS
15
15
  end
16
-
16
+
17
17
  def os_version
18
18
  os_string =~ PATTERN && $3 && $3.gsub(/_/, ".")
19
19
  end
@@ -1,22 +1,22 @@
1
1
  module Aua::OperatingSystems::Linux
2
-
2
+
3
3
  def self.extend?(agent)
4
4
  agent.platform_string == "X11" || agent.app_comments_string.match(PATTERN_LINUX)
5
5
  end
6
-
6
+
7
7
  PATTERN_LINUX = /(l|L)inux/
8
-
8
+
9
9
  def platform
10
10
  :X11
11
11
  end
12
-
12
+
13
13
  def os_name
14
14
  :Linux
15
15
  end
16
-
16
+
17
17
  def os_version
18
18
  @os_version ||= if app_comments_string =~ /OpenBSD/
19
- "OpenBSD"
19
+ "OpenBSD"
20
20
  elsif products.include?("Ubuntu")
21
21
  "Ubuntu"
22
22
  elsif products.include?("Red") && products.include?("Hat")
@@ -1,11 +1,11 @@
1
1
  module Aua::OperatingSystems::Mac
2
-
2
+
3
3
  def self.extend?(agent)
4
- agent.platform_string == "Macintosh" ||
5
- agent.os_string && agent.os_string =~ PATTERN_MACOS ||
4
+ agent.platform_string == "Macintosh" ||
5
+ agent.os_string && agent.os_string =~ PATTERN_MACOS ||
6
6
  agent.products.include?("Darwin")
7
7
  end
8
-
8
+
9
9
  PATTERN_OSX = /Mac OS X\s?([\d\._]+)?/
10
10
  PATTERN_MACOS = /Mac_PowerPC/
11
11
  DAWRWIN_2_OSX = {
@@ -37,11 +37,11 @@ module Aua::OperatingSystems::Mac
37
37
  '10.5.0' => '10.6.5',
38
38
  '10.6.0' => '10.6.6'
39
39
  }
40
-
40
+
41
41
  def platform
42
42
  darwin? && !DAWRWIN_2_OSX[version_of(:Darwin)] ? :Darwin : :Macintosh
43
43
  end
44
-
44
+
45
45
  def os_name
46
46
  @os_name ||= if osx?
47
47
  :MacOSX
@@ -51,7 +51,7 @@ module Aua::OperatingSystems::Mac
51
51
  :MacOS
52
52
  end
53
53
  end
54
-
54
+
55
55
  def os_version
56
56
  @os_version ||= if m = osx?
57
57
  m[1] ? m[1].gsub(/_/, ".") : nil
@@ -59,17 +59,17 @@ module Aua::OperatingSystems::Mac
59
59
  DAWRWIN_2_OSX[version_of(:Darwin)] || version_of(:Darwin)
60
60
  end
61
61
  end
62
-
62
+
63
63
  private
64
-
64
+
65
65
  def osx?
66
66
  app_comments_string.match PATTERN_OSX
67
67
  end
68
-
68
+
69
69
  def macos?
70
70
  app_comments_string.match PATTERN_MACOS
71
71
  end
72
-
72
+
73
73
  def darwin?
74
74
  products.include?("Darwin")
75
75
  end
@@ -4,9 +4,9 @@ module Aua::OperatingSystems::Mobiles
4
4
  agent.platform_string == "J2ME/MIDP" ||
5
5
  agent.app_comments_string =~ PATTERN_SYMBIAN
6
6
  end
7
-
7
+
8
8
  PATTERN_SYMBIAN = /Symb(ian)?\s?OS\/?([\d\.]+)?/
9
-
9
+
10
10
  def name
11
11
  @name ||= begin
12
12
  name = super
@@ -14,18 +14,18 @@ module Aua::OperatingSystems::Mobiles
14
14
  name
15
15
  end
16
16
  end
17
-
17
+
18
18
  def platform
19
19
  @platform ||= begin
20
20
  return :SymbianOS if app_comments_string =~ PATTERN_SYMBIAN
21
21
  platform_string.to_sym
22
22
  end
23
23
  end
24
-
24
+
25
25
  def os_name
26
26
  @os_name ||= platform
27
27
  end
28
-
28
+
29
29
  def os_version
30
30
  @os_version ||= begin
31
31
  return $2 if app_comments_string =~ PATTERN_SYMBIAN
@@ -1,33 +1,33 @@
1
1
  module Aua::OperatingSystems::Palm
2
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
-
3
+
4
4
  def self.extend?(agent)
5
5
  agent.platform_string =~ PATTERN && agent.products.include?("Safari")
6
6
  end
7
-
7
+
8
8
  PATTERN = /^webOS\/([\d\.]+)$/
9
-
9
+
10
10
  def platform
11
11
  @platform ||= :webOS
12
12
  end
13
-
13
+
14
14
  def os_name
15
15
  @os_name ||= :webOS
16
16
  end
17
-
17
+
18
18
  def os_version
19
19
  @os_version ||= platform_string =~ PATTERN && $1
20
20
  end
21
-
21
+
22
22
  def type
23
23
  :Browser
24
24
  end
25
-
25
+
26
26
  def name
27
27
  @name ||= :webOSWebkit
28
28
  end
29
-
29
+
30
30
  def version
31
- @version ||= version_of("Version")
31
+ @version ||= version_of("Version")
32
32
  end
33
33
  end
@@ -1,12 +1,14 @@
1
1
  module Aua::OperatingSystems::Windows
2
-
2
+
3
3
  def self.extend?(agent)
4
- agent.comments.first &&
4
+ agent.comments.first &&
5
5
  (agent.app_comments.include?("Windows") ||
6
6
  agent.comments_string =~ PATTERN)
7
7
  end
8
-
8
+
9
9
  VERSIONS = {
10
+ "NT 6.3" => "8.1",
11
+ "NT 6.2" => "8",
10
12
  "NT 6.1" => "7",
11
13
  "NT 6.0" => "Vista",
12
14
  "NT 5.2" => "XP",
@@ -19,18 +21,18 @@ module Aua::OperatingSystems::Windows
19
21
  "CE" => "CE",
20
22
  "9x 4.90" => "ME"
21
23
  }
22
-
24
+
23
25
  PATTERN = /Win(dows)?\s?([\d\sA-Zx\.]+)/
24
-
26
+
25
27
  def platform
26
28
  :Windows
27
29
  end
28
-
30
+
29
31
  def os_name
30
32
  :Windows
31
33
  end
32
-
34
+
33
35
  def os_version
34
- @os_version ||= comments_string =~ PATTERN && VERSIONS[$2] || $2
36
+ @os_version ||= comments_string =~ PATTERN && VERSIONS[$2] || $2
35
37
  end
36
38
  end
@@ -1,3 +1,3 @@
1
1
  class Aua
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -1,12 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Aua do
4
-
4
+
5
5
  describe ".parse/.new" do
6
6
  it "should be fast" do
7
7
  start = Time.now
8
8
  runs = 10
9
- runs.times do
9
+ runs.times do
10
10
  EXAMPLES.each do |string, values|
11
11
  Aua.parse string
12
12
  end
@@ -16,34 +16,36 @@ describe Aua do
16
16
  puts "#{sec} sec #{mspr} ms/string #{(EXAMPLES.size*runs/sec).to_i} strings/sec"
17
17
  mspr.should < 0.2
18
18
  end
19
-
19
+
20
20
  context "when parsing blank string" do
21
21
  let(:user_agent) { Aua.parse("") }
22
-
22
+
23
23
  it "returns an instance of Aua" do
24
24
  user_agent.should be_kind_of(Aua)
25
25
  end
26
26
  end
27
-
27
+
28
28
  context "when parsing nil" do
29
29
  let(:user_agent) { Aua.parse(nil) }
30
-
30
+
31
31
  it "returns an instance of Aua" do
32
32
  user_agent.should be_kind_of(Aua)
33
33
  end
34
34
  end
35
-
35
+
36
36
  context "when parsing unknown string" do
37
37
  let(:user_agent) { Aua.parse("Bla/1.2.3;Blupp;X/2.0.0") }
38
-
38
+
39
39
  it "returns an instance of Aua" do
40
40
  user_agent.should be_kind_of(Aua)
41
41
  end
42
42
  end
43
-
43
+
44
44
  EXAMPLES = {
45
45
  # Firefox
46
- "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; de; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13" =>
46
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:22.0) Gecko/20100101 Firefox/22.0" =>
47
+ { :type => :Browser, :name => :Firefox, :version => "22.0", :major_version => "22.0", :os_name => :MacOSX, :os_version => "10.8", :os_major_version => "10.8", :platform => :Macintosh },
48
+ "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; de; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13" =>
47
49
  { :type => :Browser, :name => :Firefox, :version => "3.6.13", :major_version => "3.6", :os_name => :MacOSX, :os_version => "10.6", :os_major_version => "10.6", :platform => :Macintosh },
48
50
  "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.11) Gecko/20101012 Firefox/3.6.11 " =>
49
51
  { :type => :Browser, :name => :Firefox, :version => "3.6.11", :major_version => "3.6", :os_name => :Windows, :os_version => "Vista", :os_major_version => "Vista", :platform => :Windows },
@@ -81,7 +83,7 @@ describe Aua do
81
83
  { :type => :Browser, :name => :Firefox, :version => "4.0b10pre", :major_version => "4.0b", :os_name => :Linux, :os_version => nil, :os_major_version => nil, :platform => :X11 },
82
84
  "Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.2.14pre) Gecko/20110113 Ubuntu/9.10 (karmic) Namoroka/3.6.14pre" =>
83
85
  { :type => :Browser, :name => :Firefox, :version => "3.6.14pre", :major_version => "3.6", :os_name => :Linux, :os_version => "Ubuntu", :platform => :X11 },
84
-
86
+
85
87
  # Firefox/Mozilla based
86
88
  "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9a9pre) Gecko/2007110108 prism/0.8" =>
87
89
  { :type => :Browser, :name => :Prism, :version => "0.8", :major_version => "0.8", :os_name => :Windows, :os_version => "7", :platform => :Windows },
@@ -107,15 +109,17 @@ describe Aua do
107
109
  { :type => :Browser, :name => :NetscapeNavigator, :version => "9.0.0.6", :os_name => :Linux, :os_version => nil, :platform => :X11 },
108
110
  "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.5) Gecko/20050519 Netscape/8.0.1" =>
109
111
  { :type => :Browser, :name => :NetscapeNavigator, :version => "8.0.1", :os_name => :Windows, :os_version => "2000", :platform => :Windows },
110
-
112
+
111
113
  # Safari
114
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/536.30.1 (KHTML, like Gecko) Version/6.0.5 Safari/536.30.1" =>
115
+ { :type => :Browser, :name => :Safari, :version => "6.0.5", :os_name => :MacOSX, :os_version => "10.8.4", :os_major_version => "10.8", :platform => :Macintosh },
112
116
  "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; de-de) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5" =>
113
117
  { :type => :Browser, :name => :Safari, :version => "5.0.2", :os_name => :MacOSX, :os_version => "10.5.8", :os_major_version => "10.5", :platform => :Macintosh },
114
118
  "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-us) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4" =>
115
119
  { :type => :Browser, :name => :Safari, :version => "5.0.3", :os_name => :MacOSX, :os_version => "10.6.6", :os_major_version => "10.6", :platform => :Macintosh },
116
120
  "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_2; de-de) AppleWebKit/531.21.8 (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10" =>
117
121
  { :type => :Browser, :name => :Safari, :version => "4.0.4", :os_name => :MacOSX, :os_version => "10.6.2", :platform => :Macintosh },
118
- "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/531.21.8 (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10" =>
122
+ "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/531.21.8 (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10" =>
119
123
  { :type => :Browser, :name => :Safari, :version => "4.0.4", :os_name => :Windows, :os_version => "XP", :platform => :Windows },
120
124
  "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_7; en-us) AppleWebKit/525.28.3 (KHTML, like Gecko) Version/3.2.3 Safari/525.28.3" =>
121
125
  { :type => :Browser, :name => :Safari, :version => "3.2.3", :os_name => :MacOSX, :os_version => "10.5.7", :platform => :Macintosh },
@@ -129,7 +133,7 @@ describe Aua do
129
133
  { :type => :Browser, :name => :Safari, :version => "1.0", :os_name => :MacOSX, :os_version => nil, :platform => :Macintosh },
130
134
  "Safari/6533.19.4 CFNetwork/454.11.5 Darwin/10.6.0 (i386) (iMac8%2C1)" =>
131
135
  { :type => :Browser, :name => :Safari, :version => "6533.19.4", :major_version => "6533.19", :os_name => :MacOSX, :os_version => "10.6.6", :platform => :Macintosh },
132
-
136
+
133
137
  # Safari based
134
138
  "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; de-de) AppleWebKit/533.18.1 (KHTML, like Gecko) Fluid/0.9.6 Safari/533.18.1" =>
135
139
  { :type => :Browser, :name => :Fluid, :version => "0.9.6", :os_name => :MacOSX, :os_version => "10.5.8", :platform => :Macintosh },
@@ -150,16 +154,18 @@ describe Aua do
150
154
  "Mozilla/5.0 (compatible; Konqueror/4.3; Linux 2.6.31-16-generic; X11) KHTML/4.3.2 (like Gecko)" =>
151
155
  { :type => :Browser, :name => :Konqueror, :version => "4.3", :os_name => :Linux, :os_version => nil, :platform => :X11 },
152
156
  "Mozilla/5.0 (compatible; Konqueror/4.0; Windows) KHTML/4.0.83 (like Gecko)" =>
153
- { :type => :Browser, :name => :Konqueror, :version => "4.0", :os_name => :Windows, :os_version => nil, :platform => :Windows },
154
-
157
+ { :type => :Browser, :name => :Konqueror, :version => "4.0", :os_name => :Windows, :os_version => nil, :platform => :Windows },
158
+
155
159
  # Chrome
160
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.71 Safari/537.36" =>
161
+ { :type => :Browser, :name => :Chrome, :version => "28.0.1500.71", :major_version => "28.0", :os_name => :MacOSX, :os_version => "10.8.4", :platform => :Macintosh },
156
162
  "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.638.0 Safari/534.16" =>
157
163
  { :type => :Browser, :name => :Chrome, :version => "10.0.638.0", :major_version => "10.0", :os_name => :Windows, :os_version => "7", :platform => :Windows },
158
164
  "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.15 (KHTML, like Gecko) Ubuntu/10.10 Chromium/10.0.613.0 Chrome/10.0.613.0 Safari/534.15" =>
159
165
  { :type => :Browser, :name => :Chrome, :version => "10.0.613.0", :os_name => :Linux, :os_version => "Ubuntu", :platform => :X11 },
160
166
  "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.231 Safari/534.10" =>
161
167
  { :type => :Browser, :name => :Chrome, :version => "8.0.552.231", :os_name => :MacOSX, :os_version => "10.6.4", :platform => :Macintosh },
162
-
168
+
163
169
  # Chrome based
164
170
  "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.237 Safari/534.10 chromeframe/8.0.552.237" =>
165
171
  { :type => :Browser, :name => :Chromeframe, :version => "8.0.552.237", :os_name => :Windows, :os_version => "7", :platform => :Windows },
@@ -171,7 +177,7 @@ describe Aua do
171
177
  { :type => :Browser, :name => :Iron, :version => "5.0.381.0", :os_name => :MacOSX, :os_version => "10.5.8", :platform => :Macintosh },
172
178
  "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-US) AppleWebKit/534.10 (KHTML, like Gecko) RockMelt/0.8.40.147 Chrome/8.0.552.231 Safari/534.10" =>
173
179
  { :type => :Browser, :name => :RockMelt, :version => "0.8.40.147", :os_name => :MacOSX, :os_version => "10.6.6", :platform => :Macintosh },
174
-
180
+
175
181
  # Opera
176
182
  "Opera/9.80 (Windows NT 6.1; U; de) Presto/2.7.62 Version/11.00" =>
177
183
  { :type => :Browser, :name => :Opera, :version => "11.00", :os_name => :Windows, :os_version => "7", :platform => :Windows },
@@ -183,11 +189,11 @@ describe Aua do
183
189
  { :type => :Browser, :name => :Opera, :version => "10.00", :os_name => :Linux, :os_version => nil, :platform => :X11 },
184
190
  "Opera/9.25 (Windows NT 6.0; U; en)" =>
185
191
  { :type => :Browser, :name => :Opera, :version => "9.25", :os_name => :Windows, :os_version => "Vista", :platform => :Windows },
186
- "Mozilla/5.0 (Macintosh; PPC Mac OS X; U; en) Opera 8.5" =>
192
+ "Mozilla/5.0 (Macintosh; PPC Mac OS X; U; en) Opera 8.5" =>
187
193
  { :type => :Browser, :name => :Opera, :version => "8.5", :os_name => :MacOSX, :os_version => nil, :platform => :Macintosh },
188
- "Mozilla/4.0 (compatible; MSIE 6.0; Mac_PowerPC Mac OS X; en) Opera 8.5" =>
194
+ "Mozilla/4.0 (compatible; MSIE 6.0; Mac_PowerPC Mac OS X; en) Opera 8.5" =>
189
195
  { :type => :Browser, :name => :Opera, :version => "8.5", :os_name => :MacOSX, :os_version => nil, :platform => :Macintosh },
190
- "Opera/8.5 (Macintosh; PPC Mac OS X; U; en)" =>
196
+ "Opera/8.5 (Macintosh; PPC Mac OS X; U; en)" =>
191
197
  { :type => :Browser, :name => :Opera, :version => "8.5", :os_name => :MacOSX, :os_version => nil, :platform => :Macintosh },
192
198
  "Opera/8.01 (Windows NT 5.1)" =>
193
199
  { :type => :Browser, :name => :Opera, :version => "8.01", :major_version => "8.01", :os_name => :Windows, :os_version => "XP", :platform => :Windows },
@@ -195,7 +201,7 @@ describe Aua do
195
201
  { :type => :Browser, :name => :Opera, :version => "8.01", :os_name => :Windows, :os_version => "XP", :platform => :Windows },
196
202
  "Mozilla/4.0 (compatible; MSIE 5.0; Windows 95) Opera 6.01 [en]" =>
197
203
  { :type => :Browser, :name => :Opera, :version => "6.01", :os_name => :Windows, :os_version => "95", :platform => :Windows },
198
-
204
+
199
205
  # Opera Mini/Mobile
200
206
  "Opera/9.80 (BlackBerry; Opera Mini/5.1.22303/22.453; U; de) Presto/2.5.25 Version/10.54" =>
201
207
  { :type => :Browser, :name => :OperaMini, :version => "5.1.22303", :os_name => :BlackBerry, :os_version => nil, :platform => :BlackBerry },
@@ -207,8 +213,14 @@ describe Aua do
207
213
  { :type => :Browser, :name => :OperaMobile, :version => "10.00", :os_name => :SymbianOS, :os_version => nil, :platform => :SymbianOS },
208
214
  "Opera/9.80 (Linux armv7l; Maemo; Opera Mobi/4; U; de) Presto/2.5.28 Version/10.1" =>
209
215
  { :type => :Browser, :name => :OperaMobile, :version => "10.1", :os_name => :Linux, :os_version => "Maemo", :platform => :X11 },
210
-
216
+
211
217
  # MSIE
218
+ "Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv 11.0) like Gecko" =>
219
+ { :type => :Browser, :name => :MSIE, :version => "11.0", :os_name => :Windows, :os_version => "8.1", :platform => :Windows },
220
+ "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)" =>
221
+ { :type => :Browser, :name => :MSIE, :version => "10.0", :os_name => :Windows, :os_version => "8", :platform => :Windows },
222
+ "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)" =>
223
+ { :type => :Browser, :name => :MSIE, :version => "10.0", :os_name => :Windows, :os_version => "7", :platform => :Windows },
212
224
  "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)" =>
213
225
  { :type => :Browser, :name => :MSIE, :version => "9.0", :os_name => :Windows, :os_version => "7", :platform => :Windows },
214
226
  "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Win64; x64; Trident/4.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Tablet PC 2.0; .NET4.0C; InfoPath.3)" =>
@@ -229,7 +241,7 @@ describe Aua do
229
241
  { :type => :Browser, :name => :MSIE, :version => "7.0", :os_name => nil, :os_version => nil, :platform => nil },
230
242
  "Mozilla/4.0 (compatible; MSIE 6.0; Windows XP)" =>
231
243
  { :type => :Browser, :name => :MSIE, :version => "6.0", :os_name => :Windows, :os_version => "XP", :platform => :Windows },
232
-
244
+
233
245
  # iPhone / iPad / iPod
234
246
  "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_1 like Mac OS X; de-de) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5" =>
235
247
  { :type => :Browser, :name => :MobileSafari, :version => "5.0.2", :os_name => :iOS, :os_version => "4.2.1", :platform => :iPhone },
@@ -241,21 +253,21 @@ describe Aua do
241
253
  { :type => :Browser, :name => :MobileSafari, :version => "3.1.1", :os_name => :iOS, :os_version => "2.1", :platform => :iPhone },
242
254
  "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1C28 Safari/419.3" =>
243
255
  { :type => :Browser, :name => :MobileSafari, :version => "3.0", :os_name => :iOS, :os_version => nil, :platform => :iPhone },
244
-
256
+
245
257
  "Mozilla/5.0 (iPod; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7" =>
246
258
  { :type => :Browser, :name => :MobileSafari, :version => "4.0.5", :os_name => :iOS, :os_version => "4.0", :platform => :iPod },
247
259
  "Mozilla/5.0 (iPod; U; CPU iPhone OS 2_2_1 like Mac OS X; en-us) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5H11a Safari/525.20" =>
248
260
  { :type => :Browser, :name => :MobileSafari, :version => "3.1.1", :os_name => :iOS, :os_version => "2.2.1", :platform => :iPod },
249
261
  "Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3A100a Safari/419.3" =>
250
262
  { :type => :Browser, :name => :MobileSafari, :version => "3.0", :os_name => :iOS, :os_version => nil, :platform => :iPod },
251
-
263
+
252
264
  "Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; es-es) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405" =>
253
265
  { :type => :Browser, :name => :MobileSafari, :version => "7B405", :major_version => "7B405", :os_name => :iOS, :os_version => "3.2.1", :platform => :iPad },
254
266
  "Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; es-es) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B405 Safari/531.21.10" =>
255
267
  { :type => :Browser, :name => :MobileSafari, :version => "4.0.4", :os_name => :iOS, :os_version => "3.2.1", :platform => :iPad },
256
268
  "Mozilla/5.0 (iPad; U; CPU OS 4_2_1 like Mac OS X; de-de) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5" =>
257
269
  { :type => :Browser, :name => :MobileSafari, :version => "5.0.2", :os_name => :iOS, :os_version => "4.2.1", :platform => :iPad },
258
-
270
+
259
271
  # Android
260
272
  "Mozilla/5.0 (Linux; U; Android 1.1; en-gb; dream) AppleWebKit/525.10+ (KHTML, like Gecko) Version/3.0.4 Mobile Safari/523.12.2" =>
261
273
  { :type => :Browser, :name => :AndroidWebkit, :version => "3.0.4", :os_name => :Android, :os_version => "1.1", :platform => :Android },
@@ -263,11 +275,11 @@ describe Aua do
263
275
  { :type => :Browser, :name => :AndroidWebkit, :version => nil, :os_name => :Android, :os_version => "0.5", :platform => :Android },
264
276
  "Mozilla/5.0 (Linux; U; Android 2.1; en-us; Nexus One Build/ERD62) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17" =>
265
277
  { :type => :Browser, :name => :AndroidWebkit, :version => "4.0", :os_name => :Android, :os_version => "2.1", :platform => :Android },
266
-
278
+
267
279
  # Palm (Pre)
268
280
  "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" =>
269
281
  { :type => :Browser, :name => :webOSWebkit, :version => "1.0", :os_name => :webOS, :os_version => "1.3", :platform => :webOS },
270
-
282
+
271
283
  # Mobiles
272
284
  "Mozilla/4.1 (compatible; MSIE 5.0; Symbian OS; Nokia 3650;424) Opera 6.10 [en]" =>
273
285
  { :type => :Browser, :name => :OperaMobile, :version => "6.10", :os_name => :SymbianOS, :os_version => nil, :platform => :SymbianOS },
@@ -283,7 +295,7 @@ describe Aua do
283
295
  { :type => :Browser, :name => :Opera, :version => "9.70", :os_name => :Windows, :os_version => "XP", :platform => :Windows },
284
296
  "Swisscom/1.0/HTC_Touch_Pro/ Opera/9.50 (Windows NT 5.1; U; de)" =>
285
297
  { :type => :Browser, :name => :Opera, :version => "9.50", :os_name => :Windows, :os_version => "XP", :platform => :Windows },
286
-
298
+
287
299
  # ApiClients
288
300
  "curl/7.20.0 (x86_64-pc-linux-gnu) libcurl/7.20.0 OpenSSL/0.9.8l zlib/1.2.3" =>
289
301
  { :type => :ApiClient, :name => :curl, :version => "7.20.0", :os_name => :Linux, :os_version => nil, :platform => :X11 },
@@ -291,7 +303,7 @@ describe Aua do
291
303
  { :type => :ApiClient, :name => :Wget, :version => "1.12", :os_name => :Linux, :os_version => nil, :platform => :X11 },
292
304
  "Wget/1.10.1 (simple)" =>
293
305
  { :type => :ApiClient, :name => :Wget, :version => "1.10.1", :os_name => nil, :os_version => nil, :platform => nil },
294
- "Yahoo Pipes 2.0" =>
306
+ "Yahoo Pipes 2.0" =>
295
307
  { :type => :ApiClient, :name => :YahooPipes, :version => "2.0", :os_name => nil, :os_version => nil, :platform => nil },
296
308
  "Zendesk" =>
297
309
  { :type => :ApiClient, :name => :Zendesk, :version => nil, :os_name => nil, :os_version => nil, :platform => nil },
@@ -327,7 +339,7 @@ describe Aua do
327
339
  { :type => :ApiClient, :name => :PythonTwistedPageGetter, :version => nil, :os_name => nil, :os_version => nil, :platform => nil },
328
340
  "facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)" =>
329
341
  { :type => :ApiClient, :name => :facebookexternalhit, :version => "1.1", :os_name => nil, :os_version => nil, :platform => nil },
330
-
342
+
331
343
  # Others
332
344
  "1PasswordThumbs/1 CFNetwork/454.11.5 Darwin/10.0.0 (i386) (MacBookPro4%2C1)" =>
333
345
  { :type => :Others, :name => :"1PasswordThumbs", :version => "1", :os_name => :MacOSX, :os_version => "10.6", :platform => :Macintosh },
@@ -337,7 +349,7 @@ describe Aua do
337
349
  { :type => :Others, :name => :MSWord, :version => "12.25.0", :os_name => :MacOSX, :os_version => nil, :platform => :Macintosh },
338
350
  "Microsoft Office/14.0 (Windows NT 6.1; Microsoft Outlook 14.0.5128; Pro; ms-office; MSOffice 14)" =>
339
351
  { :type => :Others, :name => :MSOffice, :version => "14.0", :os_name => :Windows, :os_version => "7", :platform => :Windows },
340
-
352
+
341
353
  # HttpCheckers
342
354
  "check_http/v2053 (nagios-plugins 1.4.13)" =>
343
355
  { :type => :HttpChecker, :name => :Nagios, :version => "v2053", :major_version => "v2053", :os_name => nil, :os_version => nil, :platform => nil },
@@ -349,8 +361,16 @@ describe Aua do
349
361
  { :type => :HttpChecker, :name => :W3C_Validator, :version => "1.1", :os_name => nil, :os_version => nil, :platform => nil },
350
362
  "FeedValidator/1.3" =>
351
363
  { :type => :HttpChecker, :name => :FeedValidator, :version => "1.3", :os_name => nil, :os_version => nil, :platform => nil },
352
-
364
+
353
365
  # Feed Reader/Parser
366
+ "hawkReader/0.9b (Feed Parser; http://www.hawkreader.com; Allow like Gecko)" =>
367
+ { :type => :FeedReader, :name => :hawkReader, :version => "0.9b", :os_name => nil, :os_version => nil, :platform => nil },
368
+ "Fever/1.31 (Feed Parser; http://feedafever.com; Allow like Gecko)" =>
369
+ { :type => :FeedReader, :name => :Fever, :version => "1.31", :os_name => nil, :os_version => nil, :platform => nil },
370
+ "Superfeedr bot/2.0 http://superfeedr.com - Make your feeds realtime: get in touch!" =>
371
+ { :type => :FeedReader, :name => :Superfeedr, :version => "2.0", :os_name => nil, :os_version => nil, :platform => nil },
372
+ "Feedly/1.0 (+http://www.feedly.com/fetcher.html; like FeedFetcher-Google)" =>
373
+ { :type => :FeedReader, :name => :Feedly, :version => "1.0", :os_name => nil, :os_version => nil, :platform => nil },
354
374
  "Windows-RSS-Platform/2.0 (MSIE 9.0; Windows NT 6.1)" =>
355
375
  { :type => :FeedReader, :name => :"Windows-RSS-Platform", :version => "2.0", :os_name => :Windows, :os_version => "7", :platform => :Windows },
356
376
  "Vienna/2.5.0.2501" =>
@@ -381,7 +401,7 @@ describe Aua do
381
401
  { :type => :FeedReader, :name => :TumblrRSSSyndication, :version => "1.0", :os_name => nil, :os_version => nil, :platform => nil },
382
402
  "Reeder/1010.69.00 CFNetwork/520.3.2 Darwin/11.3.0 (x86_64) (MacBookPro6%2C2)" =>
383
403
  { :type => :FeedReader, :name => :Reeder, :version => "1010.69.00", :os_name => :Darwin, :os_version => "11.3.0", :platform => :Darwin },
384
-
404
+
385
405
  # SearchBots
386
406
  "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)" =>
387
407
  { :type => :SearchBot, :name => :Bingbot, :version => "2.0", :os_name => nil, :os_version => nil, :platform => nil },
@@ -399,7 +419,7 @@ describe Aua do
399
419
  { :type => :SearchBot, :name => :Googlebot, :version => "2.1", :os_name => nil, :os_version => nil, :platform => nil },
400
420
  "DoCoMo/2.0 N905i(c100;TB;W24H16) (compatible; Googlebot-Mobile/2.1; +http://www.google.com/bot.html)" =>
401
421
  { :type => :SearchBot, :name => :GooglebotMobile, :version => "2.1", :os_name => nil, :os_version => nil, :platform => nil },
402
-
422
+
403
423
  # Engine Fallbacks
404
424
  "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-au) AppleWebKit/533.19.4 (KHTML, like Gecko)" =>
405
425
  { :type => :Browser, :name => :AppleWebKit, :version => "533.19.4", :os_name => :MacOSX, :os_version => "10.6.6", :platform => :Macintosh },
@@ -411,11 +431,11 @@ describe Aua do
411
431
  { :type => :Browser, :name => :Gecko, :version => "20070606", :major_version => "20070606", :os_name => :Linux, :os_version => "Solaris", :platform => :X11 },
412
432
  "Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.12) Gecko/20051105" =>
413
433
  { :type => :Browser, :name => :Gecko, :version => "20051105", :os_name => :Linux, :os_version => "FreeBSD", :platform => :X11 },
414
-
434
+
415
435
  "Raven/0.7.14612 CFNetwork/520.3.2 Darwin/11.3.0 (x86_64) (iMac12%2C2)" =>
416
436
  { :type => :Browser, :name => :Raven, :version => "0.7.14612", :os_name => :Darwin, :os_version => "11.3.0", :platform => :Darwin },
417
437
  }
418
-
438
+
419
439
  EXAMPLES.each do |string, values|
420
440
  context "when parsing #{string.inspect}" do
421
441
  let(:user_agent) { Aua.parse(string) }
@@ -433,65 +453,65 @@ describe Aua do
433
453
  its(:products) { should eql([]) }
434
454
  its(:versions) { should eql([]) }
435
455
  its(:comments) { should eql([]) }
436
-
456
+
437
457
  it "should return nil on #version_of" do
438
458
  subject.version_of(nil).should eql(nil)
439
459
  subject.version_of("Firefox").should eql(nil)
440
460
  end
441
-
461
+
442
462
  its(:os_string) { should eql(nil) }
443
463
  its(:platform_string) { should eql(nil) }
444
-
464
+
445
465
  its(:name) { should eql("") }
446
466
  its(:type) { should eql(:Unknown) }
447
467
  its(:version) { should eql(nil) }
448
468
  its(:os_name) { should eql(nil) }
449
469
  its(:os_version) { should eql(nil) }
450
470
  its(:platform) { should eql(nil) }
451
-
471
+
452
472
  it{ should be_unknown }
453
473
  its(:to_s) { should eql("Unknown: ")}
454
474
  end
455
-
475
+
456
476
  context "standard user agent string" do
457
477
  subject{ Aua.new("Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; de; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13") }
458
-
478
+
459
479
  its(:raw) { should eql("Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; de; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13")}
460
480
  its(:products) { should eql(["Mozilla", "Gecko", "Firefox"]) }
461
481
  its(:versions) { should eql(["5.0", "20101203", "3.6.13"]) }
462
482
  its(:comments) { should eql([["Macintosh", "U", "Intel Mac OS X 10.6", "de", "rv:1.9.2.13"], [], []]) }
463
-
483
+
464
484
  it "should return version on #version_of" do
465
485
  subject.version_of("Mozilla").should eql("5.0")
466
486
  subject.version_of("Firefox").should eql("3.6.13")
467
487
  end
468
-
488
+
469
489
  its(:platform_string) { should eql("Macintosh") }
470
490
  its(:os_string) { should eql("Intel Mac OS X 10.6") }
471
-
491
+
472
492
  it{ should_not be_unknown }
473
493
  its(:to_s) { should eql("Browser Firefox/3.6.13 MacOSX/10.6 Macintosh")}
474
494
  end
475
-
495
+
476
496
  context "unknown user agent string" do
477
497
  subject{ Aua.new("Mozilla/5.0 (Bla; U; Krank; de; rv:1.9.2.13) Less/20101203 Vrrrr/3.6.13") }
478
-
498
+
479
499
  its(:raw) { should eql("Mozilla/5.0 (Bla; U; Krank; de; rv:1.9.2.13) Less/20101203 Vrrrr/3.6.13")}
480
500
  its(:products) { should eql(["Mozilla", "Less", "Vrrrr"]) }
481
501
  its(:versions) { should eql(["5.0", "20101203", "3.6.13"]) }
482
502
  its(:comments) { should eql([["Bla", "U", "Krank", "de", "rv:1.9.2.13"], [], []]) }
483
-
503
+
484
504
  it "should return version on #version_of" do
485
505
  subject.version_of("Mozilla").should eql("5.0")
486
506
  subject.version_of("Vrrrr").should eql("3.6.13")
487
507
  end
488
-
508
+
489
509
  its(:platform_string) { should eql("Bla") }
490
510
  its(:os_string) { should eql("Krank") }
491
-
511
+
492
512
  it{ should be_unknown }
493
513
  its(:to_s) { should eql("Unknown: Mozilla/5.0 (Bla; U; Krank; de; rv:1.9.2.13) Less/20101203 Vrrrr/3.6.13")}
494
-
514
+
495
515
  its(:name) { should eql("Mozilla/5.0 (Bla; U; Krank; de; rv:1.9.2.13) Less/20101203 Vrrrr/3.6.13") }
496
516
  its(:type) { should eql(:Unknown) }
497
517
  its(:version) { should eql(nil) }
@@ -499,18 +519,18 @@ describe Aua do
499
519
  its(:os_version) { should eql(nil) }
500
520
  its(:platform) { should eql(nil) }
501
521
  end
502
-
522
+
503
523
  context "unknown simple user agent string" do
504
524
  subject{ Aua.new("my_mite_app/v1.0") }
505
-
525
+
506
526
  its(:raw) { should eql("my_mite_app/v1.0")}
507
527
  its(:products) { should eql(["my_mite_app"]) }
508
528
  its(:versions) { should eql(["v1.0"]) }
509
529
  its(:comments) { should eql([[]]) }
510
-
530
+
511
531
  it{ should be_unknown }
512
532
  its(:to_s) { should eql("Unknown: my_mite_app/v1.0 (simple)")}
513
-
533
+
514
534
  its(:name) { should eql("my_mite_app") }
515
535
  its(:type) { should eql(:Unknown) }
516
536
  its(:version) { should eql("v1.0") }