aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2015-06-06 18:10:47 -0400
committerJack Nagel2015-06-08 22:27:27 -0400
commit7d8bec3f20112151d1a295e6825ec8f5f3e9fc32 (patch)
tree7757065578581838f473ba16fb03bd5e3613f1fb /Library
parent18bb32a04db1f4b5a8a0de9a2f45b783c27e647a (diff)
downloadbrew-7d8bec3f20112151d1a295e6825ec8f5f3e9fc32.tar.bz2
Always treat formula files as UTF-8
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/formulary.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb
index b56d190a0..9ed79db07 100644
--- a/Library/Homebrew/formulary.rb
+++ b/Library/Homebrew/formulary.rb
@@ -17,7 +17,8 @@ class Formulary
def self.load_formula(name, path)
mod = Module.new
const_set("FormulaNamespace#{Digest::MD5.hexdigest(path.to_s)}", mod)
- mod.module_eval(path.read, path)
+ contents = path.open("r") { |f| set_encoding(f).read }
+ mod.module_eval(contents, path)
class_name = class_s(name)
begin
@@ -29,6 +30,16 @@ class Formulary
end
end
+ if IO.method_defined?(:set_encoding)
+ def self.set_encoding(io)
+ io.set_encoding(Encoding::UTF_8)
+ end
+ else
+ def self.set_encoding(io)
+ io
+ end
+ end
+
def self.class_s name
class_name = name.capitalize
class_name.gsub!(/[-_.\s]([a-zA-Z0-9])/) { $1.upcase }