<commit_before>#!/usr/bin/env ruby
# encoding: utf-8

require 'yaml'
require 'digest'
require 'fileutils'

def is_automated(binary)
  automated = %w(composer godep glide nginx node)
  return automated.include? binary
end

def ci_skip_for(binary)
  return !is_automated(binary)
end


binary_name  = ENV['BINARY_NAME']
builds_dir   = File.join(Dir.pwd, 'builds-yaml')
built_dir    = File.join(Dir.pwd, 'built-yaml')
builds_yaml_artifacts = File.join(Dir.pwd, 'builds-yaml-artifacts')
builds_path  = File.join(builds_dir, "#{binary_name}-builds.yml")

builds       = YAML.load_file(builds_path)
built        = YAML.load_file(File.join(built_dir, "#{binary_name}-built.yml")

latest_build = builds[binary_name].shift
built[binary_name].push latest_build

unless latest_build
  puts "There are no new builds for #{binary_name} requested."
  exit
end

if binary_name == "composer" then
  download_url = "https://getcomposer.org/download/#{latest_build['version']}/composer.phar"
  system("curl #{download_url} -o binary-builder/composer-#{latest_build['version']}.phar") or raise "Could not download composer.phar"
  FileUtils.cp_r(Dir["binary-builder/*"], "binary-builder-artifacts/")<commit_msg>Add some clarification to build-binary.rb and fix a typo<commit_after>#!/usr/bin/env ruby
# encoding: utf-8

require 'yaml'
require 'digest'
require 'fileutils'

def is_automated(binary)
  automated = %w(composer godep glide nginx node)
  return automated.include? binary
end

def ci_skip_for(binary)
  return !is_automated(binary)
end

# We read the <binary>-builds.yml file from the ./builds-yaml directory
# and the <binary>-built.yml from the ./built-yaml directory. This is because
# we want to use a specific version of builds.yml, but the latest version of
# built.yml

binary_name  = ENV['BINARY_NAME']
builds_dir   = File.join(Dir.pwd, 'builds-yaml')
built_dir    = File.join(Dir.pwd, 'built-yaml')
builds_yaml_artifacts = File.join(Dir.pwd, 'builds-yaml-artifacts')
builds_path  = File.join(builds_dir, "#{binary_name}-builds.yml")

builds       = YAML.load_file(builds_path)
built        = YAML.load_file(File.join(built_dir, "#{binary_name}-built.yml"))

latest_build = builds[binary_name].shift
built[binary_name].push latest_build

unless latest_build
  puts "There are no new builds for #{binary_name} requested."
  exit
end

if binary_name == "composer" then
  download_url = "https://getcomposer.org/download/#{latest_build['version']}/composer.phar"
  system("curl #{download_url} -o binary-builder/composer-#{latest_build['version']}.phar") or raise "Could not download composer.phar"
  FileUtils.cp_r(Dir["binary-builder/*"], "binary-builder-artifacts/")
{'fraction_non_alphanumeric': 0.13395872420262664, 'fraction_numerical': 0.00075046904315197, 'mean_word_length': 5.258215962441315, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4590622', 'n_tokens_mistral': 951, 'n_tokens_neox': 926, 'n_words': 203}