<commit_before>require 'net/http'
require 'vcr/extensions/net_http_response'

module Net
  class HTTP
    def request_with_vcr(request, body = nil, &block)
      unless VCR::HttpStubbingAdapters::FakeWeb.enabled?
        return request_without_vcr(request, body, &block)
      end

      vcr_request = VCR::Request.from_net_http_request(self, request)
      response = request_without_vcr(request, body)

      match_attributes = (cass = VCR.current_cassette) ? cass.match_requests_on : VCR::RequestMatcher::DEFAULT_MATCH_ATTRIBUTES
      if started? && !VCR.http_stubbing_adapter.request_stubbed?(vcr_request, match_attributes)
        VCR.record_http_interaction VCR::HTTPInteraction.new(vcr_request, VCR::Response.from_net_http_response(response))
        response.extend VCR::Net::HTTPResponse # "unwind" the response
      end

      yield response if block_given?
      response
    end

    alias request_without_vcr request
    alias request request_with_vcr
  end
end<commit_msg>Use if/else rather than long ternary operator.<commit_after>require 'net/http'
require 'vcr/extensions/net_http_response'

module Net
  class HTTP
    def request_with_vcr(request, body = nil, &block)
      unless VCR::HttpStubbingAdapters::FakeWeb.enabled?
        return request_without_vcr(request, body, &block)
      end

      vcr_request = VCR::Request.from_net_http_request(self, request)
      response = request_without_vcr(request, body)

      match_attributes = if cass = VCR.current_cassette
        cass.match_requests_on
      else
        VCR::RequestMatcher::DEFAULT_MATCH_ATTRIBUTES
      end

      if started? && !VCR.http_stubbing_adapter.request_stubbed?(vcr_request, match_attributes)
        VCR.record_http_interaction VCR::HTTPInteraction.new(vcr_request, VCR::Response.from_net_http_response(response))
        response.extend VCR::Net::HTTPResponse # "unwind" the response
      end

      yield response if block_given?
      response
    end

    alias request_without_vcr request
    alias request request_with_vcr
  end
end
{'fraction_non_alphanumeric': 0.07827788649706457, 'fraction_numerical': 0.0, 'mean_word_length': 4.074441687344913, 'pattern_counts': {'":': 0, '<': 3, '<?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': '902133', 'n_tokens_mistral': 645, 'n_tokens_neox': 634, 'n_words': 124}