Sha256: eed1da940aaeb94cce19a0a27174978ba42eb3801d3580ab2c9e0613e5f2c67f

Contents?: true

Size: 566 Bytes

Versions: 16

Compression:

Stored size: 566 Bytes

Contents

module Ahoy
  module Deckhands
    class TrafficSourceDeckhand
      def initialize(referrer)
        @referrer = referrer
      end

      def referring_domain
        @referring_domain ||= Addressable::URI.parse(@referrer).host.first(255) rescue nil
      end

      def search_keyword
        @search_keyword ||= (self.class.referrer_parser.parse(@referrer)[:term][0..255] rescue nil).presence
      end

      # performance hack for referer-parser
      def self.referrer_parser
        @referrer_parser ||= RefererParser::Parser.new
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ahoy_matey-1.6.1 lib/ahoy/deckhands/traffic_source_deckhand.rb
ahoy_matey-1.6.0 lib/ahoy/deckhands/traffic_source_deckhand.rb
ahoy_matey-1.5.5 lib/ahoy/deckhands/traffic_source_deckhand.rb
ahoy_matey-1.5.4 lib/ahoy/deckhands/traffic_source_deckhand.rb
ahoy_matey-1.5.3 lib/ahoy/deckhands/traffic_source_deckhand.rb
ahoy_matey-1.5.2 lib/ahoy/deckhands/traffic_source_deckhand.rb
ahoy_matey-1.5.1 lib/ahoy/deckhands/traffic_source_deckhand.rb
ahoy_matey-1.5.0 lib/ahoy/deckhands/traffic_source_deckhand.rb
ahoy_matey-1.4.2 lib/ahoy/deckhands/traffic_source_deckhand.rb
ahoy_matey-1.4.1 lib/ahoy/deckhands/traffic_source_deckhand.rb
ahoy_matey-1.4.0 lib/ahoy/deckhands/traffic_source_deckhand.rb
ahoy_matey-1.3.1 lib/ahoy/deckhands/traffic_source_deckhand.rb
ahoy_matey-1.3.0 lib/ahoy/deckhands/traffic_source_deckhand.rb
ahoy_matey-1.2.2 lib/ahoy/deckhands/traffic_source_deckhand.rb
ahoy_matey-1.2.1 lib/ahoy/deckhands/traffic_source_deckhand.rb
ahoy_matey-1.2.0 lib/ahoy/deckhands/traffic_source_deckhand.rb