<commit_before>class ExternalDependency

  class << self
    def get_or_fetch(name, threshold=30)
      name.downcase!
      Rails.cache.fetch(name, expires_in: threshold.seconds) { refresh_status(name) }
    end

    def fetch_status(name)
      name.downcase!
      status = refresh_status(name)
      Rails.cache.write(name, status, expires_in: 30.seconds)
      status
    end

    def heroku_status
      retrieve_nice_api_status 'https://status.heroku.com/api/v3/current-status'
    end

    def github_status
      retrieve_nice_api_status 'https://status.github.com/api/status.json'
    end

    def rubygems_status
      output = {}

      begin
        response_body = SynchronousHttpRequester.new('https://pclby00q90vc.statuspage.io/api/v2/status.json').retrieve_content
        output[:status] = extract_rubygems_status(response_body)
      rescue StandardError => e
        output[:status] = 'unreachable'
      end

      output.to_json
    end

    private

    def retrieve_nice_api_status url
      begin
        content = SynchronousHttpRequester.new(url).retrieve_content
      rescue<commit_msg>Fix HTTPRequesters in ExternalDependencies [#131658071]<commit_after>class ExternalDependency

  class << self
    def get_or_fetch(name, threshold=30)
      name.downcase!
      Rails.cache.fetch(name, expires_in: threshold.seconds) { refresh_status(name) }
    end

    def fetch_status(name)
      name.downcase!
      status = refresh_status(name)
      Rails.cache.write(name, status, expires_in: 30.seconds)
      status
    end

    def heroku_status
      retrieve_nice_api_status 'https://status.heroku.com/api/v3/current-status'
    end

    def github_status
      retrieve_nice_api_status 'https://status.github.com/api/status.json'
    end

    def rubygems_status
      output = {}

      begin
        net_http_builder = NetHttpBuilder.new
        response_body = SynchronousHttpRequester.new(net_http_builder).retrieve_content('https://pclby00q90vc.statuspage.io/api/v2/status.json')
        output[:status] = extract_rubygems_status(response_body)
      rescue StandardError => e
        output[:status] = 'unreachable'
      end

      output.to_json
    end

    private

    def retrieve_nice_api_status url
      begin
        net_http_builder = NetHttpBuilder.new
        content = SynchronousHttpRequester.new(net_http_builder).retrieve_content(url)
      rescue
{'fraction_non_alphanumeric': 0.08541666666666667, 'fraction_numerical': 0.012083333333333333, 'mean_word_length': 3.008347245409015, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 6, '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': '907324', 'n_tokens_mistral': 779, 'n_tokens_neox': 746, 'n_words': 123}