<commit_before>require 'yaml'
require 'fileutils'

WORK_DIR = ARGV[0]
CACHE_DIR = ARGV[1]

TRIGGER_FILE_NAME = ".buildpacks"
RELEASES_FILE_NAME = "releases_output.yml"

RELEASES_FILE = File.join(WORK_DIR,RELEASES_FILE_NAME)
TRIGGER_FILE = File.join(WORK_DIR,TRIGGER_FILE_NAME)

def log(message)
  puts "       #{message}"
end

def fix_executable_permissions(detect, compile, release)  
  `chmod +x #{detect} #{compile} #{release}`
end

def save_release_file(env_vars)
    puts "Dumping #{env_vars} \nto file"
  file = File.new(RELEASES_FILE,'w')
  YAML.dump(env_vars, file)
  file.close  
    
    puts "READING what we just wrote is#{YAML.load(File.read(RELEASES_FILE)).inspect}"
end

def read_release_file
  YAML.load(File.read(RELEASES_FILE))<commit_msg>Trying to doctor stuff a bit.<commit_after>require 'yaml'
require 'fileutils'

WORK_DIR = ARGV[0]
CACHE_DIR = ARGV[1]

TRIGGER_FILE_NAME = ".buildpacks"
RELEASES_FILE_NAME = "releases_output.yml"

RELEASES_FILE = File.join(WORK_DIR,RELEASES_FILE_NAME)
TRIGGER_FILE = File.join(WORK_DIR,TRIGGER_FILE_NAME)

def log(message)
  puts "       #{message}"
end

def fix_executable_permissions(detect, compile, release)  
  `chmod +x #{detect} #{compile} #{release}`
end

def save_release_file(env_vars)
  env_vars.gsub!(/---/,'')
  env_vars = "---\n#{env_vars}"
  file = File.new(RELEASES_FILE,'w')
  YAML.dump(env_vars, file)
  file.close  
  puts "Using combined release:\n#{YAML.load(File.read(RELEASES_FILE))}"
end

def read_release_file
  YAML.load(File.read(RELEASES_FILE))
{'fraction_non_alphanumeric': 0.13211249182472204, 'fraction_numerical': 0.002616088947024199, 'mean_word_length': 5.455696202531645, 'pattern_counts': {'":': 0, '<': 3, '<?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': '716525', 'n_tokens_mistral': 616, 'n_tokens_neox': 623, 'n_words': 107}