From b48d46d4bc33de817e2dda02c4fc23de4a6d977d Mon Sep 17 00:00:00 2001 From: Max Howell Date: Fri, 19 Feb 2010 15:56:21 +0000 Subject: [PATCH] Allow inreplace to operate over arrays I like that String.each is interchangeable with Array.each :) --- Library/Homebrew/utils.rb | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 3f89e187a2..911fe488fc 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -195,18 +195,20 @@ module HomebrewInreplaceExtension end def inreplace path, before=nil, after=nil - f = File.open(path, 'r') - s = f.read + path.each do |path| + f = File.open(path, 'r') + s = f.read - if before == nil and after == nil - s.extend(HomebrewInreplaceExtension) - yield s - else - s.gsub!(before, after) + if before == nil and after == nil + s.extend(HomebrewInreplaceExtension) + yield s + else + s.gsub!(before, after) + end + + f.reopen(path, 'w').write(s) + f.close end - - f.reopen(path, 'w').write(s) - f.close end def ignore_interrupts