<commit_before>class Repositories
  class Hex < Base
    HAS_VERSIONS = true
    HAS_DEPENDENCIES = true
    URL = 'https://hex.pm'

    def self.project_names
      page = 1
      projects = []
      while true
        r = get("https://hex.pm/api/packages?page=#{page}")
        break if r == []
        projects += r
        page +=1
      end
      projects.map{|project| project['name'] }
    end

    def self.project(name)
      get("https://hex.pm/api/packages/#{name}")
    end

    def self.mapping(project)
      links = project["meta"].fetch("links", {}).each_with_object({}) do |(k, v), h|
        h[k.downcase] = v
      end
      {
        :name => project["name"],
        :homepage => links.except('github').first.try(:last),
        :repository_url => links['github'],
        :description => project["meta"]["description"],
        :licenses => repo_fallback(project["meta"].fetch("licenses", []).join(','), links.except('github').first.try(:last))
      }
    end

    def self.versions(project)
      project["releases"].map do |version|
        {
          :number => version['version'],
          :published_at => version['created_at']
        }
      end
    end
  end
end<commit_msg>Hex dependency downloading<commit_after>class Repositories
  class Hex < Base
    HAS_VERSIONS = true
    HAS_DEPENDENCIES = true
    URL = 'https://hex.pm'

    def self.project_names
      page = 1
      projects = []
      while true
        r = get("https://hex.pm/api/packages?page=#{page}")
        break if r == []
        projects += r
        page +=1
      end
      projects.map{|project| project['name'] }
    end

    def self.project(name)
      get("https://hex.pm/api/packages/#{name}")
    end

    def self.mapping(project)
      links = project["meta"].fetch("links", {}).each_with_object({}) do |(k, v), h|
        h[k.downcase] = v
      end
      {
        :name => project["name"],
        :homepage => links.except('github').first.try(:last),
        :repository_url => links['github'],
        :description => project["meta"]["description"],
        :licenses => repo_fallback(project["meta"].fetch("licenses", []).join(','), links.except('github').first.try(:last))
      }
    end

    def self.versions(project)
      project["releases"].map do |version|
        {
          :number => version['version'],
          :published_at => version['created_at']
        }
      end
    end

    def self.dependencies(name, version)
      deps = get("https://hex.pm/api/packages/#{name}/releases/#{version}")['requirements']
      return nil if deps.nil?
      deps.map do |k, v|
        {
          project_name: k,
          requirements: v['requirement'],
          kind: 'normal',
          optional: v['optional'],
          platform: self.name.demodulize
        }
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.16460176991150444, 'fraction_numerical': 0.001415929203539823, 'mean_word_length': 2.2150170648464163, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 7, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2723630', 'n_tokens_mistral': 872, 'n_tokens_neox': 854, 'n_words': 172}