<commit_before>require "net/http"

$vagrant_files = {}
$vagrant_os = []

$vagrant_os_mappings = {
  ".deb" => "debian",
  ".dmg" => "darwin",
  ".msi" => "windows",
  ".rpm" => "rpm",
}

$vagrant_os_order  = ["darwin", "windows", "debian", "rpm"]
$vagrant_downloads = {}
$vagrant_versions  = []

if ENV["VAGRANT_VERSION"]
  puts "Finding downloads for Vagrant"
  raise "BINTRAY_API_KEY must be set." if !ENV["BINTRAY_API_KEY"]
  http = Net::HTTP.new("dl.bintray.com", 80)
  req = Net::HTTP::Get.new("/mitchellh/vagrant/")
  req.basic_auth "<PASSWORD>", ENV["BINTRAY_API_KEY"]
  response = http.request(req)

  response.body.split("\n").each do |line|
    next if line !~ /#(vagrant_.+?)"/
    filename = $1.to_s

    # Ignore any files that don't appear to have a version in it
    next if filename !~ /[-_]?(\d+\.\d+\.\d+[^-_.]*)/
    version = Gem::Version.new($1.to_s)
    $vagrant_downloads[version] ||= {}

    $vagrant_os_mappings.each do |suffix, os|
      if filename.end_with?(suffix)
        $vagrant_downloads[version][os] ||= []
        $vagrant_downloads[version][os] << filename
      end
    end
  end

  $vagrant_versions = $vagrant_downloads.keys.sort.reverse
  $vagrant_versions.each do |v|
    puts "- Version #{v} found"
  end
else<commit_msg>website/www: use bintray API<commit_after>require "json"
require "net/http"
require "net/https"

$vagrant_files = {}
$vagrant_os = []

$vagrant_os_mappings = {
  ".deb" => "debian",
  ".dmg" => "darwin",
  ".msi" => "windows",
  ".rpm" => "rpm",
}

$vagrant_os_order  = ["darwin", "windows", "debian", "rpm"]
$vagrant_downloads = {}
$vagrant_versions  = []

if ENV["VAGRANT_VERSION"]
  puts "Finding downloads for Vagrant"
  raise "BINTRAY_API_KEY must be set." if !ENV["BINTRAY_API_KEY"]
  http = Net::HTTP.new("bintray.com", 443)
  http.use_ssl = true
  req = Net::HTTP::Get.new("/api/v1/packages/mitchellh/vagrant/vagrant/files")
  req.basic_auth "mitchellh", ENV["BINTRAY_API_KEY"]
  response = http.request(req)
  data = JSON.parse(response.body)

  data.each do |file|
    filename = file["name"]

    # Ignore any files that don't appear to have a version in it
    next if filename !~ /[-_]?(\d+\.\d+\.\d+[^-_.]*)/
    version = Gem::Version.new($1.to_s)
    $vagrant_downloads[version] ||= {}

    $vagrant_os_mappings.each do |suffix, os|
      if filename.end_with?(suffix)
        $vagrant_downloads[version][os] ||= []
        $vagrant_downloads[version][os] << filename
      end
    end
  end

  $vagrant_versions = $vagrant_downloads.keys.sort.reverse
  $vagrant_versions.each do |v|
    puts "- Version #{v} found"
  end
else
{'fraction_non_alphanumeric': 0.1800383877159309, 'fraction_numerical': 0.00345489443378119, 'mean_word_length': 3.6870503597122304, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3616811', 'n_tokens_mistral': 1057, 'n_tokens_neox': 1024, 'n_words': 196}