Module: FileUtils
- Defined in:
- lib/fileutils_logger.rb
Defined Under Namespace
Classes: LoggerAdapter
Class Method Summary collapse
-
.cd(dir, options = {}, &block) ⇒ Object
Monkey patch original source code is here: github.com/ruby/ruby/blob/v2_0_0_247/lib/fileutils.rb#L122.
-
.chdir ⇒ Object
Monkey patch original source code is here: github.com/ruby/ruby/blob/v2_0_0_247/lib/fileutils.rb#L122.
- .with_logger(logger, level = :info) ⇒ Object
Class Method Details
.cd(dir, options = {}, &block) ⇒ Object
Monkey patch original source code is here:
https://github.com/ruby/ruby/blob/v2_0_0_247/lib/fileutils.rb#L122
11 12 13 14 15 16 17 |
# File 'lib/fileutils_logger.rb', line 11 def cd(dir, = {}, &block) # :yield: dir , OPT_TABLE['cd'] "cd #{dir}" if [:verbose] r = Dir.chdir(dir, &block) 'cd -' if [:verbose] and block return r # this is difference from original and this is important! end |
.chdir ⇒ Object
Monkey patch original source code is here:
https://github.com/ruby/ruby/blob/v2_0_0_247/lib/fileutils.rb#L122
20 21 22 23 24 25 26 |
# File 'lib/fileutils_logger.rb', line 20 def cd(dir, = {}, &block) # :yield: dir , OPT_TABLE['cd'] "cd #{dir}" if [:verbose] r = Dir.chdir(dir, &block) 'cd -' if [:verbose] and block return r # this is difference from original and this is important! end |
.with_logger(logger, level = :info) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/fileutils_logger.rb', line 24 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(" def \#{name}(*args)\n super(*fu_update_option(args, :verbose => true))\n end\n private :\#{name}\n EOS\n end\n\n extend self\n class << self\n ::FileUtils::METHODS.each do |m|\n public m\n end\n end\n end\n\nend\n", __FILE__, __LINE__ + 1) |