aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Nagel2013-07-11 21:55:02 -0500
committerJack Nagel2013-07-12 16:23:06 -0500
commit7c68757e99909e705fefa0ca4d3b2a48f4fd9f64 (patch)
tree3d99fc219782d6e72655c4e3ef5d8ac2c3e05837
parent196afb43172ac9cc3a3ab452a547231c60fef2e3 (diff)
downloadhomebrew-7c68757e99909e705fefa0ca4d3b2a48f4fd9f64.tar.bz2
Move inreplace off of Object
Closes #21163.
-rw-r--r--Library/Homebrew/formula.rb1
-rw-r--r--Library/Homebrew/utils.rb22
-rw-r--r--Library/Homebrew/utils/inreplace.rb24
3 files changed, 26 insertions, 21 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index 0135726ac..ec1659c94 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -14,6 +14,7 @@ require 'formulary'
class Formula
include FileUtils
+ include Utils::Inreplace
extend BuildEnvironmentDSL
attr_reader :name, :path, :homepage, :downloader
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index 800ec0544..2786d6b7a 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -2,6 +2,7 @@ require 'pathname'
require 'exceptions'
require 'macos'
require 'utils/json'
+require 'utils/inreplace'
require 'open-uri'
class Tty
@@ -213,27 +214,6 @@ def archs_for_command cmd
Pathname.new(cmd).archs
end
-def inreplace paths, before=nil, after=nil
- Array(paths).each do |path|
- f = File.open(path, 'r')
- s = f.read
-
- if before.nil? && after.nil?
- s.extend(StringInreplaceExtension)
- yield s
- else
- sub = s.gsub!(before, after)
- if sub.nil?
- opoo "inreplace in '#{path}' failed"
- puts "Expected replacement of '#{before}' with '#{after}'"
- end
- end
-
- f.reopen(path, 'w').write(s)
- f.close
- end
-end
-
def ignore_interrupts(opt = nil)
std_trap = trap("INT") do
puts "One sec, just cleaning up" unless opt == :quietly
diff --git a/Library/Homebrew/utils/inreplace.rb b/Library/Homebrew/utils/inreplace.rb
new file mode 100644
index 000000000..4b3cf9587
--- /dev/null
+++ b/Library/Homebrew/utils/inreplace.rb
@@ -0,0 +1,24 @@
+module Utils
+ module Inreplace
+ def inreplace paths, before=nil, after=nil
+ Array(paths).each do |path|
+ f = File.open(path, 'r')
+ s = f.read
+
+ if before.nil? && after.nil?
+ s.extend(StringInreplaceExtension)
+ yield s
+ else
+ sub = s.gsub!(before, after)
+ if sub.nil?
+ opoo "inreplace in '#{path}' failed"
+ puts "Expected replacement of '#{before}' with '#{after}'"
+ end
+ end
+
+ f.reopen(path, 'w').write(s)
+ f.close
+ end
+ end
+ end
+end