aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMax Howell2010-02-19 15:56:21 +0000
committerMax Howell2010-02-19 17:34:40 +0000
commitb48d46d4bc33de817e2dda02c4fc23de4a6d977d (patch)
tree7a31dab0ee6234220884c6d9a8399fdc81d19a1f /Library
parent0d73cbbc5353327005ba57e5528efa4a522de82b (diff)
downloadbrew-b48d46d4bc33de817e2dda02c4fc23de4a6d977d.tar.bz2
Allow inreplace to operate over arrays
I like that String.each is interchangeable with Array.each :)
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/utils.rb22
1 files changed, 12 insertions, 10 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index 3f89e187a..911fe488f 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)
- end
+ 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
+ f.reopen(path, 'w').write(s)
+ f.close
+ end
end
def ignore_interrupts