Sha256: e21237e2178387c0aceaf236e86e3b1e72c76d940fdabe538c14ee88eff17530

Contents?: true

Size: 644 Bytes

Versions: 3

Compression:

Stored size: 644 Bytes

Contents

module Sniffles
  module Sniffers
    class GoogleAnalytics
      include Text
      
      attr_accessor :doc
      attr_reader :output
      
      def initialize(response_body)
        @output = {}        
        parse(response_body) && process_document
      end
      
      def process_document
        if @output[:found] = found?
          parse_google_analytics_ua
        end
      end
      
      private
      def found?
        match?(/google\-analytics\.com\/ga\.js|urchinTracker/i)
      end
      
      def parse_google_analytics_ua
        @output[:ua] = capture(/[\"|\'](UA\-[\d]+\-[\d])[\"|\']/)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sniffles-0.1.5 lib/sniffles/sniffers/analytics/google_analytics.rb
sniffles-0.1.4 lib/sniffles/sniffers/analytics/google_analytics.rb
sniffles-0.1.3 lib/sniffles/sniffers/analytics/google_analytics.rb