Ruby Issue Tracking System: Issueshttps://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112012-10-31T00:42:43ZRuby Issue Tracking System
Redmine Ruby master - Bug #7246 (Closed): FileUtils.cp_r does not preserve attributes of directorieshttps://redmine.ruby-lang.org/issues/72462012-10-31T00:42:43Zwedesoft (Jan Wedekind)
<p>(({FileUtils.cp_r})) does not preserve the file attributes of directories because the attributes are set before copying to the directory.<br>
The following monkey patch fixes this behaviour. However the monkey patch relies on the contents of the source directory not changing during the copy operation.</p>
<p>(({require 'fileutils'</p>
<p>def copy_entry(src, dest, preserve = false, dereference_root = false, remove_destination = false)<br>
Entry_.new(src, nil, dereference_root).traverse do |ent|<br>
destent = Entry_.new(dest, ent.rel, false)<br>
File.unlink destent.path if remove_destination && File.file?(destent.path)<br>
ent.copy destent.path<br>
end<br>
Entry_.new(src, nil, dereference_root).postorder_traverse do |ent|<br>
destent = Entry_.new(dest, ent.rel, false)<br>
ent.copy_metadata destent.path if preserve<br>
end<br>
end<br>
module_function :copy_entry</p>
<p>end}))</p> Ruby master - Bug #1135 (Closed): Problem renaming CMath.hypot in Ruby1.9https://redmine.ruby-lang.org/issues/11352009-02-10T23:00:02Zwedesoft (Jan Wedekind)
<p>=begin</p>
<a name="Running-the-following-program-with-Ruby19-"></a>
<h1 >Running the following program with Ruby1.9 ...<a href="#Running-the-following-program-with-Ruby19-" class="wiki-anchor">¶</a></h1>
<p>require 'complex'<br>
class Module<br>
def alias_method_chain( target, feature )<br>
alias_method "#{target}<em>without</em>#{feature}", target<br>
alias_method target, "#{target}<em>with</em>#{feature}"<br>
end<br>
end<br>
Math.module_eval do<br>
define_method( :hypot_with_test ) do |a,b|<br>
puts "hypot_with_test( #{a}, #{b} )"<br>
hypot_without_test( a, b )<br>
end<br>
alias_method_chain :hypot, :test<br>
module_function :hypot_without_test<br>
module_function :hypot<br>
end<br>
puts Math.hypot( 3, 4 )</p>
<a name="-results-in-this-error"></a>
<h1 >... results in this error:<a href="#-results-in-this-error" class="wiki-anchor">¶</a></h1>
<a name="trb14in-module_function-undefined-method-hypot_without_test-for-module-CMath-NameError"></a>
<h1 >t.rb:14:in <code>module_function': undefined method </code>hypot_without_test' for module `CMath' (NameError)<a href="#trb14in-module_function-undefined-method-hypot_without_test-for-module-CMath-NameError" class="wiki-anchor">¶</a></h1>
<a name="from-trb14in-block-in-"></a>
<h1 >from t.rb:14:in `block in '<a href="#from-trb14in-block-in-" class="wiki-anchor">¶</a></h1>
<a name="from-trb8in-module_eval"></a>
<h1 >from t.rb:8:in `module_eval'<a href="#from-trb8in-module_eval" class="wiki-anchor">¶</a></h1>
<a name="from-trb8in-"></a>
<h1 >from t.rb:8:in `<a href="#from-trb8in-" class="wiki-anchor">¶</a></h1>
<h1></h1>
<a name="Using-Ruby-186-the-same-program-runs-without-error-The-problem-also-does-not-occur-if-complex-is-not-loaded"></a>
<h1 >Using Ruby 1.8.6 the same program runs without error. The problem also does not occur if 'complex' is not loaded.<a href="#Using-Ruby-186-the-same-program-runs-without-error-The-problem-also-does-not-occur-if-complex-is-not-loaded" class="wiki-anchor">¶</a></h1>
<p>=end</p>