diff options
| author | Adam Vandenberg | 2010-11-12 21:05:35 -0800 |
|---|---|---|
| committer | Adam Vandenberg | 2011-03-12 11:55:03 -0800 |
| commit | 65f840fb0649dbdee9af01f7f2446af97924f80a (patch) | |
| tree | b0ff836c7d978f8cce5a53a98007a6c1bf87abbc /Library/Homebrew/utils.rb | |
| parent | faaa1ad4b1c4e069dd6e6809391b999b9bfef586 (diff) | |
| download | homebrew-65f840fb0649dbdee9af01f7f2446af97924f80a.tar.bz2 | |
Move string extensions
Diffstat (limited to 'Library/Homebrew/utils.rb')
| -rw-r--r-- | Library/Homebrew/utils.rb | 25 |
1 files changed, 1 insertions, 24 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 6dedf764b..e478670fb 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -169,36 +169,13 @@ def archs_for_command cmd archs.extend(ArchitectureListExtension) end -# String extensions added by inreplace below. -module HomebrewInreplaceExtension - # Looks for Makefile style variable defintions and replaces the - # value with "new_value", or removes the definition entirely. - def change_make_var! flag, new_value - new_value = "#{flag}=#{new_value}" - gsub! Regexp.new("^#{flag}[ \\t]*=[ \\t]*(.*)$"), new_value - end - # Removes variable assignments completely. - def remove_make_var! flags - flags.each do |flag| - # Also remove trailing \n, if present. - gsub! Regexp.new("^#{flag}[ \\t]*=(.*)$\n?"), "" - end - end - # Finds the specified variable - def get_make_var flag - m = match Regexp.new("^#{flag}[ \\t]*=[ \\t]*(.*)$") - return m[1] if m - return nil - end -end - def inreplace path, before=nil, after=nil [*path].each do |path| f = File.open(path, 'r') s = f.read if before == nil and after == nil - s.extend(HomebrewInreplaceExtension) + s.extend(StringInreplaceExtension) yield s else s.gsub!(before, after) |
