<commit_before># frozen_string_literal: true

module DeepCover
  module Load
    AUTOLOAD = %i[analyser autoload_tracker auto_run config
                  coverage covered_code custom_requirer
                  flag_comment_associator global_variables memoize module_override node
                  persistence problem_with_diagnostic reporter
                 ]

    def load_absolute_basics
      require_relative 'base'
      require_relative 'basics'
      require_relative 'config_setter'
      require_relative 'tools/camelize'
      AUTOLOAD.each do |module_name|
        DeepCover.autoload(Tools::Camelize.camelize(module_name), "#{__dir__}/#{module_name}")
      end
      DeepCover.autoload :VERSION, "#{__dir__}/version"
      Object.autoload :Term, 'term/ansicolor'
      Object.autoload :Terminal, 'terminal-table'
      Object.autoload :YAML, 'yaml'
      Object.autoload :Forwardable, 'forwardable'
      Object.autoload :JSON, 'json'
    end

    def bootstrap
      @bootstrapped ||= false # Avoid warning
      return if @bootstrapped
      require_relative 'backports'
      require_relative 'tools'
      @bootstrapped = true
    end

    def load_parser
      @parser_loaded ||= false # Avoid warning
      return if @parser_loaded
      Tools.silence_warnings do
        require 'parser'
        require 'parser/current'
      end<commit_msg>Ruby 2.2 and less fix to autoload gems<commit_after># frozen_string_literal: true

module DeepCover
  module Load
    AUTOLOAD = %i[analyser autoload_tracker auto_run config
                  coverage covered_code custom_requirer
                  flag_comment_associator global_variables memoize module_override node
                  persistence problem_with_diagnostic reporter
                 ]

    def load_absolute_basics
      require_relative 'base'
      require_relative 'basics'
      require_relative 'config_setter'
      require_relative 'tools/camelize'
      AUTOLOAD.each do |module_name|
        DeepCover.autoload(Tools::Camelize.camelize(module_name), "#{__dir__}/#{module_name}")
      end
      DeepCover.autoload :VERSION, "#{__dir__}/version"

      Object.autoload :Forwardable, 'forwardable'
      Object.autoload :YAML, 'yaml'

      # In ruby 2.2 and less, autoload doesn't work for gems which are not already on the `$LOAD_PATH`.
      # The fix is to just require right away for those rubies
      #
      # Low-level: autoload not working for gems not on the `$LOAD_PATH` is because those rubies don't
      # call the regular `#require` when triggering an autoload, and the gem system monkey-patches `#require`
      # so that when a file is not found in the `$LOAD_PATH`, but can be found in an existing gem, that gem's
      # path is added to the `$LOAD_PATH`
      {JSON: 'json',
       Term: 'term/ansicolor',
       Terminal: 'terminal-table',
      }.each do |const, require_path|
        if RUBY_VERSION < '2.3'
          require require_path
        else
          Object.autoload const, require_path
        end
      end
    end

    def bootstrap
      @bootstrapped ||= false # Avoid warning
      return if @bootstrapped
      require_relative 'backports'
      require_relative 'tools'
      @bootstrapped = true
    end

    def load_parser
      @parser_loaded ||= false # Avoid warning
      return if @parser_loaded
      Tools.silence_warnings do
        require 'parser'
        require 'parser/current'
      end
{'fraction_non_alphanumeric': 0.07138694638694638, 'fraction_numerical': 0.0017482517482517483, 'mean_word_length': 2.632804232804233, 'pattern_counts': {'":': 0, '<': 4, '<?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': '6251182', 'n_tokens_mistral': 1019, 'n_tokens_neox': 985, 'n_words': 282}