<commit_before>require 'fileutils'
require 'logger'

module FileUtils

  class << self
    def with_logger(logger, level = :info)
      output = LoggerAdapter.new(logger, level)

      Module.new do
        include FileUtils
        @fileutils_output  = output
        @fileutils_label   = ''

        ::FileUtils.collect_method(:verbose).each do |name|
          module_eval(<<-EOS, __FILE__, __LINE__ + 1)
            def #{name}(*args)
              super(*fu_update_option(args, :verbose => true))
            end
            private :#{name}
          EOS
        end

        extend self
        class << self
          ::FileUtils::METHODS.each do |m|
            public m
          end
        end
      end<commit_msg>overwrite FileUtils#cd to return block result as same as Dir.chdir<commit_after>require 'fileutils'
require 'logger'

module FileUtils

  def cd(dir, options = {}, &block) # :yield: dir
    fu_check_options options, OPT_TABLE['cd']
    fu_output_message "cd #{dir}" if options[:verbose]
    r = Dir.chdir(dir, &block)
    fu_output_message 'cd -' if options[:verbose] and block
    r
  end
  module_function :cd

  alias chdir cd
  module_function :chdir

  class << self
    def with_logger(logger, level = :info)
      output = LoggerAdapter.new(logger, level)

      Module.new do
        include FileUtils
        @fileutils_output  = output
        @fileutils_label   = ''

        ::FileUtils.collect_method(:verbose).each do |name|
          module_eval(<<-EOS, __FILE__, __LINE__ + 1)
            def #{name}(*args)
              super(*fu_update_option(args, :verbose => true))
            end
            private :#{name}
          EOS
        end

        extend self
        class << self
          ::FileUtils::METHODS.each do |m|
            public m
          end
        end
      end
{'fraction_non_alphanumeric': 0.09961685823754789, 'fraction_numerical': 0.0010946907498631637, 'mean_word_length': 2.0065789473684212, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 5, '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': '6526353', 'n_tokens_mistral': 543, 'n_tokens_neox': 531, 'n_words': 142}