Sha256: 4ffb4b6a8f8c7dade91ebc13a052e547460f5ff669b55dd60edc5c85be6da2dc

Contents?: true

Size: 1.27 KB

Versions: 7

Compression:

Stored size: 1.27 KB

Contents

module Aua::Agents::ApiClients
  KNOWN_CLIENTS = %w(facebookexternalhit Wget curl Zend_Http_Client Zendesk Python-httplib2 Python-urllib Ruby PEAR HTTP_Request2 NativeHost Java AppEngine-Google Twisted)

  def self.extend?(agent)
    KNOWN_CLIENTS.include?(agent.app) ||
    agent.raw =~ PATTERN_YAHOO_PIPES ||
    agent.app =~ PATTERN_GERMAN_SYSTEM_PREFS ||
    agent.app =~ PATTERN_SYSTEM_UI_SEVER
  end

  PATTERN_YAHOO_PIPES         = /^Yahoo Pipes ([\d\.]+)$/
  PATTERN_GERMAN_SYSTEM_PREFS = /^Systemeinstellungen/
  PATTERN_SYSTEM_UI_SEVER     = /^SystemUIServer/

  def type
    :ApiClient
  end

  def name
    @name ||= begin
      if raw =~ PATTERN_YAHOO_PIPES
        :YahooPipes
      elsif app == "PEAR" || app == "HTTP_Request2"
        :PearPHPHttpRequest
      elsif app == "NativeHost"
        :CappucinosNativeHost
      elsif app =~ PATTERN_GERMAN_SYSTEM_PREFS
        :SystemPreferences
      elsif app =~ PATTERN_SYSTEM_UI_SEVER
        :SystemUIServer
      elsif app == "Twisted"
        :PythonTwistedPageGetter
      else
        app.to_sym
      end
    end
  end

  def version
    @version ||= begin
      return $1 if raw =~ /^Yahoo Pipes ([\d\.]+)$/
      return comments.first[1] if name == :"AppEngine-Google" && comments.first[1]
      versions.first
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
aua-0.3.2 lib/aua/agents/api_clients.rb
aua-0.3.1 lib/aua/agents/api_clients.rb
aua-0.3.0 lib/aua/agents/api_clients.rb
aua-0.2.6 lib/aua/agents/api_clients.rb
aua-0.2.5 lib/aua/agents/api_clients.rb
aua-0.2.4 lib/aua/agents/api_clients.rb
aua-0.2.3 lib/aua/agents/api_clients.rb