<commit_before>module YmlRecord
  # Returns an array of [filename, scenario name, description]
  def self.yml_headers_old
    output = []
    Dir.foreach(Settings.app_path + "scenarios-yml/") do |filename|
      next if filename == '.' or filename == '..' or filename == 'ddos.yml'
      scenario = YAML.load_file(Settings.app_path + "scenarios-yml/#{filename}")["Scenarios"][0]
      name = scenario["Name"]
      description = scenario["Description"]
      output.push [filename, name, description]
    end
    return output
  end

  def self.yml_headers(location, user)
    output = []

    if location == 'custom'
      path = Settings.app_path + "scenarios/custom/#{user.id}"
    else
      path = Settings.app_path + "scenarios/#{location}"
    end

    Dir.foreach(path) do |filename|
      next if filename == '.' or filename == '..'<commit_msg>add checking for scenario path<commit_after>module YmlRecord
  # Returns an array of [filename, scenario name, description]
  def self.yml_headers_old
    output = []
    Dir.foreach(Settings.app_path + "scenarios-yml/") do |filename|
      next if filename == '.' or filename == '..' or filename == 'ddos.yml'
      scenario = YAML.load_file(Settings.app_path + "scenarios-yml/#{filename}")["Scenarios"][0]
      name = scenario["Name"]
      description = scenario["Description"]
      output.push [filename, name, description]
    end
    return output
  end

  def self.yml_headers(location, user)
    output = []

    if location == 'custom'
      path = Settings.app_path + "scenarios/custom/#{user.id}"
    else
      path = Settings.app_path + "scenarios/#{location}"
    end

    Dir.mkdir path unless File.exists? path

    Dir.foreach(path) do |filename|
      next if filename == '.' or filename == '..'
{'fraction_non_alphanumeric': 0.13744343891402716, 'fraction_numerical': 0.0011312217194570137, 'mean_word_length': 3.1235431235431235, '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': '3466505', 'n_tokens_mistral': 557, 'n_tokens_neox': 540, 'n_words': 135}