xsawyerx / ref-util-rewriter

Rewrite your code to use Ref::Util
Other
1 stars 2 forks source link

rewrite_file overwrite previous content #10

Closed atoomic closed 5 years ago

atoomic commented 5 years ago
Pod mention that 'rewrite_file' "rewrite the file in place"
but obsiously it does not and simply return the updated content
instead.

This commit is adding a unit test and fixes 'rewrite_file' by
preserving the original behavior of returning the updated content.
(instead of a boolean as we could expect)
atoomic commented 5 years ago

also tested with steps from #9 after patch

> perl -Ilib -MRef::Util::Rewriter -E 'use Test::More; note "Before:\n", qx[cat test.pl]; Ref::Util::Rewriter::rewrite_file( "test.pl" ); note "After:\n", qx[cat test.pl];'
# Before:
#
# sub is_array {
#
#     return ref $_[0] eq 'ARRAY';
# }
#
# 1;
# After:
#
# sub is_array {
#
#     return is_arrayref($_[0]);
# }
#
# 1;
atoomic commented 5 years ago

note that 5d8b84ee98c5df30a7fb0e4064d4740eb1ccc947 can be cherry picked on top of master as itself, but was not able to perform tests without patches from #6

atoomic commented 5 years ago

Travis CI build https://travis-ci.org/atoomic/ref-util-rewriter/builds/526979756

xsawyerx commented 5 years ago

Merged the relevant commit. Thanks! :+1: