aua 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 151b1188bb70816f5c6d7fb672f076e2078f6c85
4
+ data.tar.gz: 444d7b614e154e29215f8d2f040f215611c42bfd
5
+ SHA512:
6
+ metadata.gz: f01a7678393ff7c60341aec8e265bbad4fad94241df54ef608ddf44c19a8e63e0817bc97ff65cbd33d850a375c7eb5da127c9184050c3f74d8dea2247e2e3627
7
+ data.tar.gz: e66bd417b312cd54968bc35a38d176d62ac70b1531750b1b652045cb2bbd415f3e8de612b6ed48ce77cc0ec28b2936e93450ab850ba3e97aa56339ee94d74faa
data/.gitignore CHANGED
@@ -1,3 +1,6 @@
1
1
  pkg/*
2
2
  *.gem
3
3
  .bundle
4
+ .ruby-version
5
+ Gemfile.lock
6
+ tmp/*
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 1.9.3
5
+ - 1.8.7
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in aua.gemspec
4
4
  gemspec
5
+
6
+ gem "rake"
data/Guardfile CHANGED
@@ -1,4 +1,4 @@
1
- guard 'rspec', :version => 2 do
1
+ guard 'rspec' do
2
2
  watch(/^spec\/(.*)_spec\.rb/) { "spec" }
3
3
  watch(/^lib\/(.*)\.rb/) { "spec" } # { |m| "spec/#{m[1]}_spec.rb" }
4
4
  watch(/^spec\/spec_helper\.rb/) { "spec" }
@@ -18,9 +18,9 @@ Gem::Specification.new do |s|
18
18
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
-
22
- s.add_development_dependency 'rspec', '>= 2.4.0'
23
- s.add_development_dependency 'guard-rspec', '>=0.1.9'
24
- s.add_development_dependency 'growl', '>=1.0.3'
25
- s.add_development_dependency 'rb-fsevent', '>=0.3.9'
21
+
22
+ s.add_development_dependency 'rspec', '>= 2.4'
23
+ s.add_development_dependency 'guard-rspec', '>=3.0'
24
+ s.add_development_dependency 'growl', '>=1.0'
25
+ s.add_development_dependency 'rb-fsevent', '>=0.9'
26
26
  end
data/lib/aua.rb CHANGED
@@ -9,11 +9,11 @@ class Aua
9
9
  @raw = string.to_s
10
10
  parse
11
11
  end
12
-
12
+
13
13
  def self.parse(raw)
14
14
  new(raw)
15
15
  end
16
-
16
+
17
17
  def parse
18
18
  string = @raw.dup
19
19
  @parts = []
@@ -21,13 +21,13 @@ class Aua
21
21
  @parts << [m[1] ? m[1].sub(/;$/,"") : m[1], m[2], m[4] ? m[4].split(/\s?;\s?/) : []]
22
22
  string = string.sub(m[0], '').strip
23
23
  end
24
-
24
+
25
25
  Aua::Agents.extend_agent(self)
26
26
  Aua::OperatingSystems.extend_agent(self)
27
27
  end
28
28
 
29
29
  attr_reader :version, :os_name, :os_version, :parts, :raw, :platform
30
-
30
+
31
31
  def name
32
32
  @name unless unknown?
33
33
  if simple?
@@ -36,25 +36,25 @@ class Aua
36
36
  raw
37
37
  end
38
38
  end
39
-
39
+
40
40
  def type
41
41
  @type || :Unknown
42
42
  end
43
-
43
+
44
44
  def version
45
45
  @version ||= name ? version_of(name) : nil
46
46
  end
47
-
47
+
48
48
  MAJOR_VERSION = /^([\d]+)\.([\d]+[a-z]*)/
49
-
49
+
50
50
  def major_version
51
51
  @major_version ||= (version || "") =~ MAJOR_VERSION ? "#{$1}.#{$2}" : version
52
52
  end
53
-
53
+
54
54
  def os_major_version
55
55
  @os_major_version ||= (os_version || "") =~ MAJOR_VERSION ? "#{$1}.#{$2}" : os_version
56
56
  end
57
-
57
+
58
58
  def products
59
59
  @products ||= parts.map{|p| p[0] }
60
60
  end
@@ -62,7 +62,7 @@ class Aua
62
62
  def versions
63
63
  @versions ||= parts.map{|p| p[1] != "" ? p[1] : nil }
64
64
  end
65
-
65
+
66
66
  def app
67
67
  products[0]
68
68
  end
@@ -70,15 +70,15 @@ class Aua
70
70
  def comments
71
71
  @comments ||= parts.map{|p| p[2] }
72
72
  end
73
-
73
+
74
74
  def app_comments
75
75
  @app_comments ||= (comments.first || []) + [""]*5
76
76
  end
77
-
77
+
78
78
  def app_comments_string
79
79
  @app_comments_string ||= (comments.first || []).join(";")
80
80
  end
81
-
81
+
82
82
  def comments_string
83
83
  @comments_string ||= comments.flatten.join(";")
84
84
  end
@@ -95,15 +95,15 @@ class Aua
95
95
  def os_string
96
96
  @os_string ||= comments.first && comments.first[2]
97
97
  end
98
-
98
+
99
99
  def unknown?
100
100
  type == :Unknown
101
101
  end
102
-
102
+
103
103
  def simple?
104
104
  products.size == 1 && versions.size <= 1 && comments == [[]]
105
105
  end
106
-
106
+
107
107
  def to_s
108
108
  return "Unknown: #{raw}#{" (simple)" if simple?}" if unknown?
109
109
  "#{type} #{name}/#{version} #{os_name}/#{os_version} #{platform}"
@@ -4,13 +4,13 @@ class Aua
4
4
  module Agents
5
5
  extend StackBase
6
6
  extend self
7
-
7
+
8
8
  def default
9
9
  @default ||= [HttpChecker, ApiClients, FeedReader, Firefox, Chrome::Frame, Chrome, Safari, Opera, Msie, SearchBot, Konqueror, Others, EngineFallback, OtherBrowsers]
10
10
  end
11
11
  end
12
12
  end
13
13
 
14
- Dir["#{File.dirname(__FILE__)}/agents/*.rb"].each do |agent|
14
+ Dir["#{File.dirname(__FILE__)}/agents/*.rb"].each do |agent|
15
15
  require(agent)
16
16
  end
@@ -1,21 +1,21 @@
1
1
  module Aua::Agents::ApiClients
2
2
  KNOWN_CLIENTS = %w(facebookexternalhit Wget curl Zend_Http_Client Zendesk Python-httplib2 Python-urllib Ruby PEAR HTTP_Request2 NativeHost Java AppEngine-Google Twisted)
3
-
3
+
4
4
  def self.extend?(agent)
5
5
  KNOWN_CLIENTS.include?(agent.app) ||
6
6
  agent.raw =~ PATTERN_YAHOO_PIPES ||
7
7
  agent.app =~ PATTERN_GERMAN_SYSTEM_PREFS ||
8
8
  agent.app =~ PATTERN_SYSTEM_UI_SEVER
9
9
  end
10
-
10
+
11
11
  PATTERN_YAHOO_PIPES = /^Yahoo Pipes ([\d\.]+)$/
12
12
  PATTERN_GERMAN_SYSTEM_PREFS = /^Systemeinstellungen/
13
13
  PATTERN_SYSTEM_UI_SEVER = /^SystemUIServer/
14
-
14
+
15
15
  def type
16
16
  :ApiClient
17
17
  end
18
-
18
+
19
19
  def name
20
20
  @name ||= begin
21
21
  if raw =~ PATTERN_YAHOO_PIPES
@@ -35,12 +35,12 @@ module Aua::Agents::ApiClients
35
35
  end
36
36
  end
37
37
  end
38
-
38
+
39
39
  def version
40
40
  @version ||= begin
41
41
  return $1 if raw =~ /^Yahoo Pipes ([\d\.]+)$/
42
42
  return comments.first[1] if name == :"AppEngine-Google" && comments.first[1]
43
- versions.first
43
+ versions.first
44
44
  end
45
45
  end
46
46
  end
@@ -2,11 +2,11 @@ module Aua::Agents::Chrome
2
2
  def self.extend?(agent)
3
3
  agent.products.include?("Safari") && agent.products.include?("Chrome")
4
4
  end
5
-
5
+
6
6
  def type
7
7
  :Browser
8
8
  end
9
-
9
+
10
10
  def name
11
11
  @name ||= begin
12
12
  return :Iron if products.include?("Iron")
@@ -14,7 +14,7 @@ module Aua::Agents::Chrome
14
14
  :Chrome
15
15
  end
16
16
  end
17
-
17
+
18
18
  module Frame
19
19
  def self.extend?(agent)
20
20
  agent.products.include?("chromeframe")
@@ -4,11 +4,11 @@ module Aua::Agents::EngineFallback
4
4
  (agent.products.include?("AppleWebKit") ||
5
5
  agent.products.include?("Gecko"))
6
6
  end
7
-
7
+
8
8
  def type
9
9
  :Browser
10
10
  end
11
-
11
+
12
12
  def name
13
13
  @name ||= begin
14
14
  return :AppleWebKit if products.include?("AppleWebKit")
@@ -1,21 +1,21 @@
1
1
  module Aua::Agents::FeedReader
2
- KNOWN_CLIENTS = %w(Reeder AppleSyndication Netvibes Windows-RSS-Platform Vienna NewsGatorOnline NewsFire NetNewsWire MWFeedParser SimplePie MagpieRSS Feedfetcher-Google Apple-PubSub)
3
-
2
+ KNOWN_CLIENTS = %w(hawkReader Fever Superfeedr Feedly Reeder AppleSyndication Netvibes Windows-RSS-Platform Vienna NewsGatorOnline NewsFire NetNewsWire MWFeedParser SimplePie MagpieRSS Feedfetcher-Google Apple-PubSub)
3
+
4
4
  def self.extend?(agent)
5
5
  KNOWN_CLIENTS.include?(agent.app) ||
6
6
  (agent.app == "Tumblr" && agent.products.include?("RSS") && agent.products.include?("syndication"))
7
7
  end
8
-
8
+
9
9
  def type
10
10
  :FeedReader
11
11
  end
12
-
12
+
13
13
  def name
14
14
  return :TumblrRSSSyndication if app == "Tumblr"
15
15
  app.to_sym
16
16
  end
17
-
17
+
18
18
  def version
19
- @version ||= versions.first
19
+ @version ||= versions[0] || versions[1]
20
20
  end
21
21
  end
@@ -1,14 +1,14 @@
1
1
  module Aua::Agents::Firefox
2
2
  PATTERN = /^(Firefox|(p|P)rism|SeaMonkey|Camino|Iceweasel|Thunderbird|Epiphany|Namoroka|Flock|Navigator|Netscape)/
3
-
3
+
4
4
  def self.extend?(agent)
5
5
  agent.products.find{|product| product =~ PATTERN}
6
6
  end
7
-
7
+
8
8
  def type
9
9
  :Browser
10
10
  end
11
-
11
+
12
12
  def name
13
13
  @name ||= begin
14
14
  if products.include?("Prism") || products.include?("prism")
@@ -28,7 +28,7 @@ module Aua::Agents::Firefox
28
28
  :Firefox
29
29
  end
30
30
  end
31
-
31
+
32
32
  def version
33
33
  @version ||= begin
34
34
  return version_of("Namoroka") if products.include?("Namoroka")
@@ -1,16 +1,16 @@
1
1
  module Aua::Agents::HttpChecker
2
2
  KNOWN_CLIENTS = %w(check_http NewRelicPinger W3C_Validator FeedValidator)
3
-
3
+
4
4
  def self.extend?(agent)
5
5
  agent.app &&
6
6
  (KNOWN_CLIENTS.include?(agent.app) ||
7
7
  agent.app =~ /Pingdom\.com_bot_version_/)
8
8
  end
9
-
9
+
10
10
  def type
11
11
  :HttpChecker
12
12
  end
13
-
13
+
14
14
  def name
15
15
  @name ||= begin
16
16
  return :PingdomBot if app =~ /Pingdom\.com_bot_version_([\d\.]+)/
@@ -18,11 +18,11 @@ module Aua::Agents::HttpChecker
18
18
  app.to_sym
19
19
  end
20
20
  end
21
-
21
+
22
22
  def version
23
23
  @version ||= begin
24
24
  return $1 if app =~ /Pingdom\.com_bot_version_([\d\.]+)/
25
- versions.first
25
+ versions.first
26
26
  end
27
27
  end
28
28
  end
@@ -3,17 +3,17 @@ module Aua::Agents::Konqueror
3
3
  agent.products.include?("KHTML") &&
4
4
  agent.app_comments[1] =~ PATTERN
5
5
  end
6
-
6
+
7
7
  PATTERN = /Konqueror\/([\d\.]+)/
8
-
8
+
9
9
  def type
10
10
  :Browser
11
11
  end
12
-
12
+
13
13
  def name
14
14
  @name ||= :Konqueror
15
15
  end
16
-
16
+
17
17
  def version
18
18
  @version ||= app_comments[1] =~ PATTERN && $1
19
19
  end
@@ -1,23 +1,26 @@
1
1
  module Aua::Agents::Msie
2
-
2
+
3
3
  def self.extend?(agent)
4
4
  agent.app_comments_string =~ PATTERN
5
5
  end
6
-
7
- PATTERN = /MSIE ([\d.]+)/
8
-
6
+
7
+ PATTERN = /(MSIE |Trident\/)([\d.]+)/
8
+ TRIDENT_VERSION_MAP = {
9
+ "7.0" => "11.0"
10
+ }
11
+
9
12
  def type
10
13
  :Browser
11
14
  end
12
-
15
+
13
16
  def name
14
17
  :MSIE
15
18
  end
16
-
19
+
17
20
  def version
18
21
  @version ||= begin
19
22
  app_comments_string =~ PATTERN
20
- $1
23
+ $1 == "Trident\/" ? TRIDENT_VERSION_MAP[$2] || $2 : $2
21
24
  end
22
25
  end
23
26
  end
@@ -2,15 +2,15 @@ module Aua::Agents::Opera
2
2
  def self.extend?(agent)
3
3
  agent.products.include?("Opera")
4
4
  end
5
-
5
+
6
6
  PATTERN = /Opera ([\d.]+)/
7
7
  PATTERN_MINI = /Opera Mini\/([\d.]+)/
8
8
  PATTERN_MOBILE = /Opera Mobi\//
9
-
9
+
10
10
  def type
11
11
  :Browser
12
12
  end
13
-
13
+
14
14
  def name
15
15
  @name ||= begin
16
16
  return :OperaMobile if app_comments_string =~ PATTERN_MOBILE
@@ -18,7 +18,7 @@ module Aua::Agents::Opera
18
18
  :Opera
19
19
  end
20
20
  end
21
-
21
+
22
22
  def version
23
23
  @version ||= begin
24
24
  return $1 if app_comments[1] =~ PATTERN_MINI
@@ -1,14 +1,14 @@
1
1
  module Aua::Agents::OtherBrowsers
2
2
  KNOWN_CLIENTS = %w(Raven)
3
-
3
+
4
4
  def self.extend?(agent)
5
5
  KNOWN_CLIENTS.include?(agent.app)
6
6
  end
7
-
7
+
8
8
  def type
9
9
  :Browser
10
10
  end
11
-
11
+
12
12
  def name
13
13
  products[0].to_sym
14
14
  end