<commit_before># encoding: UTF-8
module CranBrowserBackend
  class PackagesFetcher
    BASE_URL = "http://cran.r-project.org/src/contrib/"
    FILE_TYPE = "tar.gz"

    def self.fetch(packages_to_fetch)
      packages_to_fetch.map do |package|
        package_data = { url: BASE_URL + package["Package"] + '_' + package["Version"] + '.' + FILE_TYPE,
          file_name: package["Package"] + '_' + package["Version"] + '.' + FILE_TYPE,
          directory_name: package["Package"]}
        PackageFetcher.fetch(package_data)
      end
    end
  end<commit_msg>refactor: extract code to method<commit_after># encoding: UTF-8
module CranBrowserBackend
  class PackagesFetcher
    BASE_URL = "http://cran.r-project.org/src/contrib/"
    FILE_TYPE = "tar.gz"

    class << self
      def fetch(packages_to_fetch)
        packages_to_fetch.map do |package|
          @package = package
          PackageFetcher.fetch(get_package_data)
        end
      end

      private

      def get_package_data
        { url: BASE_URL + @package["Package"] + '_' + @package["Version"] + '.' + FILE_TYPE,
            file_name: @package["Package"] + '_' + @package["Version"] + '.' + FILE_TYPE,
            directory_name: @package["Package"]}
      end
    end
  end
{'fraction_non_alphanumeric': 0.1312, 'fraction_numerical': 0.0016, 'mean_word_length': 2.802431610942249, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4219738', 'n_tokens_mistral': 400, 'n_tokens_neox': 395, 'n_words': 75}