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

PARTING_LINE = "-------------------------------"

puts PARTING_LINE
puts Dir.entries(".")

puts PARTING_LINE
Dir.entries(".").each do |file|
  puts file
end

# カレントディレクトリから再帰的にrubyスクリプトを表示する
puts PARTING_LINE
count = 0
Dir.glob("**/*.rb").each do |file|
  puts file
  count += 1
end
puts "[file count = #{count}]"
<commit_msg>YAML sample added<commit_after>#!/usr/bin/ruby
# coding: utf-8

PARTING_LINE = "-------------------------------"

puts PARTING_LINE
puts Dir.entries(".")

puts PARTING_LINE
Dir.entries(".").each do |file|
  puts file
end

# カレントディレクトリから再帰的にrubyスクリプトを表示する
puts PARTING_LINE
count = 0
Dir.glob("**/*.rb").each do |file|
  puts file
  count += 1
end
puts "[file count = #{count}]"

# yamlの基本操作
require 'yaml'

puts PARTING_LINE
elements = [
  { "name" => "hoge",
    "country" => "fuga",
    "age" => 14,
    "hobby" => ["game", "bycycle", "cooking"]
  }
]
puts YAML.dump(elements)

open("elements.yml", "w") do |file|
  YAML.dump(elements, file)
end

puts PARTING_LINE
loaded = YAML.load_file("elements.yml")
puts loaded

# RailsのMySQL用のDB設定の出力、読み込み
db_config = {
  "development" => 
  { "adapter" => "mysql2",
    "encoding" => "utf8",
    "database" => "develop",
    "pool" => 5,
    "username" => "root",
    "password" => "",
    "host" => "localhost"
  }
}
open("database.yml", "w") do |file|
  YAML.dump(db_config, file)
end

puts PARTING_LINE
database = YAML.load_file("database.yml")
params = [
  "adapter",
  "encoding",
  "database",
  "pool",
  "username",
  "password",
  "host"]
params.each do |param|
  puts "#{param}: #{database["development"][param]}"
end
{'fraction_non_alphanumeric': 0.21532846715328466, 'fraction_numerical': 0.006690997566909975, 'mean_word_length': 3.3866666666666667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '6007387', 'n_tokens_mistral': 699, 'n_tokens_neox': 669, 'n_words': 141}