<commit_before>module ReTrack
  module Tracker
    extend ActiveSupport::Concern

    included do
      before_filter :rt_track_referer
    end

    private

      TRACK = {
        referer_url: -> (request) { request.headers['HTTP_REFERER'].presence || 'none' },
        first_url: -> (request) { request.url },
        user_agent: -> (request) { request.env['HTTP_USER_AGENT'] },
        first_visited_at: -> (request) { Time.now },
        ip: -> (request) { request.remote_ip },
        accept_language: -> (request) { request.env['HTTP_ACCEPT_LANGUAGE'] },
        forwarded_ip: -> (request) { request.env['HTTP_X_FORWARDED_FOR'] || request.env['HTTP_CLIENT_IP'] }
      }

      def rt_track_referer
        session[:retrack].nil? && !request_from_a_known_bot? &&
          session[:retrack] = Hash[TRACK.map { |k, v| [k, v.call(request)] }]
      end
<commit_msg>ruby 1.9 compatibility<commit_after>module ReTrack
  module Tracker
    extend ActiveSupport::Concern

    included do
      before_filter :rt_track_referer
    end

    private

      TRACK = {
        referer_url: ->(request) { request.headers['HTTP_REFERER'].presence || 'none' },
        first_url: ->(request) { request.url },
        user_agent: ->(request) { request.env['HTTP_USER_AGENT'] },
        first_visited_at: ->(request) { Time.now },
        ip: ->(request) { request.remote_ip },
        accept_language: ->(request) { request.env['HTTP_ACCEPT_LANGUAGE'] },
        forwarded_ip: ->(request) { request.env['HTTP_X_FORWARDED_FOR'] || request.env['HTTP_CLIENT_IP'] }
      }

      def rt_track_referer
        session[:retrack].nil? && !request_from_a_known_bot? &&
          session[:retrack] = Hash[TRACK.map { |k, v| [k, v.call(request)] }]
      end

{'fraction_non_alphanumeric': 0.14753157290470723, 'fraction_numerical': 0.001148105625717566, 'mean_word_length': 2.9345372460496613, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5488993', 'n_tokens_mistral': 585, 'n_tokens_neox': 580, 'n_words': 96}