<commit_before>require 'faraday'
require 'core_ext/hash/compact'
require 'core_ext/hash/deep_symbolize_keys'
require 'active_support/core_ext/string'
require 'active_support/core_ext/class/attribute'
require 'travis/support/logging'
require 'travis/support/exceptions'

module Travis
  class Task
    include Logging

    class_attribute :run_local

    class << self
      extend Exceptions::Handling

      def run(queue, *args)
        Travis::Async.run(self, :perform, async_options(queue), *args)
      end

      def perform(*args)
        new(*args).run
      end
    end

    attr_reader :payload, :params

    def initialize(payload, params = {})
      @payload = payload.deep_symbolize_keys
      @params  = params.deep_symbolize_keys
    end

    def run
      timeout after: params[:timeout] || 60 do
        process
      end
    end

    private

      def repository
        @repository ||= payload[:repository]
      end

      def job
        @job ||= payload[:job]
      end

      def build
        @build ||= payload[:build]
      end

      def request
        @request ||= payload[:request]
      end

      def commit
        @commit ||= payload[:commit]
      end

      def pull_request?
        build[:pull_request]
      end

      def http
        @http ||= Faraday.new(http_options) do |f|
          f.request :url_encoded
          f.adapter :net_http
        end
      end<commit_msg>Define pull_request_number<commit_after>require 'faraday'
require 'core_ext/hash/compact'
require 'core_ext/hash/deep_symbolize_keys'
require 'active_support/core_ext/string'
require 'active_support/core_ext/class/attribute'
require 'travis/support/logging'
require 'travis/support/exceptions'

module Travis
  class Task
    include Logging

    class_attribute :run_local

    class << self
      extend Exceptions::Handling

      def run(queue, *args)
        Travis::Async.run(self, :perform, async_options(queue), *args)
      end

      def perform(*args)
        new(*args).run
      end
    end

    attr_reader :payload, :params

    def initialize(payload, params = {})
      @payload = payload.deep_symbolize_keys
      @params  = params.deep_symbolize_keys
    end

    def run
      timeout after: params[:timeout] || 60 do
        process
      end
    end

    private

      def repository
        @repository ||= payload[:repository]
      end

      def job
        @job ||= payload[:job]
      end

      def build
        @build ||= payload[:build]
      end

      def request
        @request ||= payload[:request]
      end

      def commit
        @commit ||= payload[:commit]
      end

      def pull_request?
        build[:pull_request]
      end

      def pull_request_number
        if pull_request?
          payload[:pull_request_number]
        end
      end

      def http
        @http ||= Faraday.new(http_options) do |f|
          f.request :url_encoded
          f.adapter :net_http
        end
      end
{'fraction_non_alphanumeric': 0.08983451536643026, 'fraction_numerical': 0.0013508949679162446, 'mean_word_length': 2.205627705627706, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '5748940', 'n_tokens_mistral': 897, 'n_tokens_neox': 860, 'n_words': 211}