Allow inreplace to operate over arrays
I like that String.each is interchangeable with Array.each :)
This commit is contained in:
parent
0d73cbbc53
commit
b48d46d4bc
@ -195,18 +195,20 @@ module HomebrewInreplaceExtension
|
|||||||
end
|
end
|
||||||
|
|
||||||
def inreplace path, before=nil, after=nil
|
def inreplace path, before=nil, after=nil
|
||||||
f = File.open(path, 'r')
|
path.each do |path|
|
||||||
s = f.read
|
f = File.open(path, 'r')
|
||||||
|
s = f.read
|
||||||
|
|
||||||
if before == nil and after == nil
|
if before == nil and after == nil
|
||||||
s.extend(HomebrewInreplaceExtension)
|
s.extend(HomebrewInreplaceExtension)
|
||||||
yield s
|
yield s
|
||||||
else
|
else
|
||||||
s.gsub!(before, after)
|
s.gsub!(before, after)
|
||||||
|
end
|
||||||
|
|
||||||
|
f.reopen(path, 'w').write(s)
|
||||||
|
f.close
|
||||||
end
|
end
|
||||||
|
|
||||||
f.reopen(path, 'w').write(s)
|
|
||||||
f.close
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def ignore_interrupts
|
def ignore_interrupts
|
||||||
|
Loading…
x
Reference in New Issue
Block a user