<commit_before>class Repositories
  class NPM < Base
    HAS_VERSIONS = true
    HAS_DEPENDENCIES = true

    def self.project_names
      HTTParty.get("http://registry.npmjs.org/-/all/").parsed_response.keys[1..-1]
    end

    def self.project(name)
      HTTParty.get("http://registry.npmjs.org/#{name}").parsed_response
    end

    def self.keys
      ["_id", "_rev", "name", "description", "dist-tags", "versions", "readme", "maintainers", "time", "author", "repository", "users", "homepage", "keywords", "bugs", "readmeFilename", "_attachments"]
    end

    def self.mapping(project)
      return false unless project["versions"].present?
      latest_version = project["versions"].to_a.last[1]
      {
        :name => project["name"],
        :description => project["description"],
        :homepage => project["homepage"],
        :keywords => project.fetch("keywords", []).join(','),
        :licenses => Array.wrap(latest_version.fetch('licenses', [])).map{|l| l['type'] }.join(',')
      }
    end

    def self.versions(project)
      project['time'].except("modified", "created").map do |k,v|
        {
          :number => k,
          :published_at => v
        }
      end
    end
  end
end<commit_msg>Stupid npm version differences<commit_after>class Repositories
  class NPM < Base
    HAS_VERSIONS = true
    HAS_DEPENDENCIES = true

    def self.project_names
      HTTParty.get("http://registry.npmjs.org/-/all/").parsed_response.keys[1..-1]
    end

    def self.project(name)
      HTTParty.get("http://registry.npmjs.org/#{name}").parsed_response
    end

    def self.keys
      ["_id", "_rev", "name", "description", "dist-tags", "versions", "readme", "maintainers", "time", "author", "repository", "users", "homepage", "keywords", "bugs", "readmeFilename", "_attachments"]
    end

    def self.mapping(project)
      return false unless project["versions"].present?
      latest_version = project["versions"].to_a.last[1]
      {
        :name => project["name"],
        :description => project["description"],
        :homepage => project["homepage"],
        :keywords => project.fetch("keywords", []).join(','),
        :licenses => Array.wrap(latest_version.fetch('licenses', [])).map{|l| l['type'] }.join(',')
      }
    end

    def self.versions(project)
      if project['time']
        project['time'].except("modified", "created").map do |k,v|
          {
            :number => k,
            :published_at => v
          }
        end
      else
        project['versions'].map do |_k, v|
          { :number => v['version'] }
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.17572741194486982, 'fraction_numerical': 0.002297090352220521, 'mean_word_length': 2.72753209700428, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 18, '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': '1842283', 'n_tokens_mistral': 831, 'n_tokens_neox': 795, 'n_words': 161}