<commit_before>require "language_pack"
require "language_pack/base"

class LanguagePack::Ruby < LanguagePack::Base

  def self.use?
    File.exist?("Gemfile")
  end

  def name
    "Ruby"
  end

  def default_addons
    []
  end

  def default_config_vars
    {
      "LANG" => "en_US.UTF-8",
      "PATH" => default_path,
      "GEM_PATH" => slug_vendor_base
    }
  end

  def default_process_types
    { "rake" => "bundle exec rake",
      "console" => "bundle exec irb" }
  end

  def compile
    Dir.chdir(build_path)
    setup_language_pack_environment
    git_dir = ENV.delete("GIT_DIR") # can mess with bundler
    build_bundler
    create_database_yml
    run_compile_hook
    ENV["GIT_DIR"] = git_dir
  end

private

  def default_path
    "#{slug_vendor_base}/bin:/usr/local/bin:/usr/bin:/bin"
  end

  def language_pack_gems
    File.expand_path("../../../vendor/gems", __FILE__)
  end

  def slug_vendor_base
    "vendor/bundle/ruby/1.9.1"
  end

  def setup_language_pack_environment
    default_config_vars.each do |key, value|
      ENV[key] = value
    end
    ENV["GEM_HOME"] = slug_vendor_base
  end

  def install_language_pack_gems
    FileUtils.mkdir_p(File.dirname(slug_vendor_base))
    FileUtils.cp_r("#{language_pack_gems}/.", slug_vendor_base, :preserve => true)
  end

  def build_bundler
    bundle_vendor = "#{slug_vendor_base}/gems/bundler-1.1.pre.1"
    bundle_command = "bundle install --without development:test --path vendor/bundle"

    unless File.exist?("Gemfile.lock")
      error "Gemfile.lock is required. Please run \"bundle install\" locally\nand commit your Gemfile.lock."
    end

    if has_windows_gemfile_lock?
      File.rm("Gemfile.lock")
    else
      bundle_command += " --deployment"
    end

    cache_load ".bundle"
    cache_load "vendor/bundle"
<commit_msg>File.unlink, not File.rm<commit_after>require "language_pack"
require "language_pack/base"

class LanguagePack::Ruby < LanguagePack::Base

  def self.use?
    File.exist?("Gemfile")
  end

  def name
    "Ruby"
  end

  def default_addons
    []
  end

  def default_config_vars
    {
      "LANG" => "en_US.UTF-8",
      "PATH" => default_path,
      "GEM_PATH" => slug_vendor_base
    }
  end

  def default_process_types
    { "rake" => "bundle exec rake",
      "console" => "bundle exec irb" }
  end

  def compile
    Dir.chdir(build_path)
    setup_language_pack_environment
    git_dir = ENV.delete("GIT_DIR") # can mess with bundler
    build_bundler
    create_database_yml
    run_compile_hook
    ENV["GIT_DIR"] = git_dir
  end

private

  def default_path
    "#{slug_vendor_base}/bin:/usr/local/bin:/usr/bin:/bin"
  end

  def language_pack_gems
    File.expand_path("../../../vendor/gems", __FILE__)
  end

  def slug_vendor_base
    "vendor/bundle/ruby/1.9.1"
  end

  def setup_language_pack_environment
    default_config_vars.each do |key, value|
      ENV[key] = value
    end
    ENV["GEM_HOME"] = slug_vendor_base
  end

  def install_language_pack_gems
    FileUtils.mkdir_p(File.dirname(slug_vendor_base))
    FileUtils.cp_r("#{language_pack_gems}/.", slug_vendor_base, :preserve => true)
  end

  def build_bundler
    bundle_vendor = "#{slug_vendor_base}/gems/bundler-1.1.pre.1"
    bundle_command = "bundle install --without development:test --path vendor/bundle"

    unless File.exist?("Gemfile.lock")
      error "Gemfile.lock is required. Please run \"bundle install\" locally\nand commit your Gemfile.lock."
    end

    if has_windows_gemfile_lock?
      File.unlink("Gemfile.lock")
    else
      bundle_command += " --deployment"
    end

    cache_load ".bundle"
    cache_load "vendor/bundle"

{'fraction_non_alphanumeric': 0.11275720164609053, 'fraction_numerical': 0.003840877914951989, 'mean_word_length': 3.1291053227633068, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7188595', 'n_tokens_mistral': 1326, 'n_tokens_neox': 1257, 'n_words': 252}