Navigation Menu

Skip to content

Commit

Permalink
Use extend instead of singleton method
Browse files Browse the repository at this point in the history
Singleton method disables Marshal.dump.
  • Loading branch information
kou committed Feb 13, 2013
1 parent 664d156 commit 6785595
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions mroonga.rb
Expand Up @@ -62,30 +62,31 @@ def caveats
end

private
def build_mysql_formula
mysql = Formula.factory("mysql")
class << mysql
have_patches = (instance_method(:patches).owner == ancestors.first)
if have_patches
def patches
file_content = path.open do |file|
file.read
end
data = path.open
data.seek(file_content.index(/^__END__$/) + "__END__¥n".size)
data
end
module AbortInstall
def patches
file_content = path.open do |file|
file.read
end
data_index = file_content.index(/^__END__$/)
return super if data_index.nil?

def system(command_line, *args)
if command_line == "make install"
throw :abort_install
else
super(command_line, *args)
end
data = path.open
data.seek(data_index + "__END__¥n".size)
data
end

def system(command_line, *args)
if command_line == "make install"
throw :abort_install
else
super(command_line, *args)
end
end
end

def build_mysql_formula
mysql = Formula.factory("mysql")
mysql.extend(AbortInstall)
mysql.brew do
catch(:abort_install) do
mysql.install
Expand Down

0 comments on commit 6785595

Please sign in to comment.