Sha256: 4c46d40ad748c2bd492b4a046379a2097e2da5559b5bd0319f03f0ded63b2521

Contents?: true

Size: 602 Bytes

Versions: 4

Compression:

Stored size: 602 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)[1].first(255) rescue nil).presence
      end

      # performance hack for referer-parser
      def self.referrer_parser
        @referrer_parser ||= RefererParser::Referer.new("https://github.com/ankane/ahoy")
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ahoy_matey-1.1.0 lib/ahoy/deckhands/traffic_source_deckhand.rb
ahoy_matey-1.0.2 lib/ahoy/deckhands/traffic_source_deckhand.rb
ahoy_matey-1.0.1 lib/ahoy/deckhands/traffic_source_deckhand.rb
ahoy_matey-1.0.0 lib/ahoy/deckhands/traffic_source_deckhand.rb