aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
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 }