Permalink
Browse files

Requirement: env DSL is evaluated in context of self, not ENV

This was meant to support:

  env do |req|
    append_path 'PATH', req.some_method
    ...
  end

i.e., the block was evaluated in the context of ENV. But it turned out
to be not so useful after all, so I'm ripping it out before something
actually depends on it.
  • Loading branch information...
1 parent 734f082 commit d839567f1fd3c45b9e709a937c0924ac24b89a71 @jacknagel jacknagel committed Apr 1, 2013
View
4 Library/Homebrew/build_environment.rb
@@ -22,8 +22,8 @@ def userpaths?
@settings.include? :userpaths
end
- def modify_build_environment(context=nil)
- @procs.each { |p| ENV.instance_exec(context, &p) }
+ def modify_build_environment(receiver)
+ @procs.each { |p| receiver.instance_eval(&p) }
end
def _dump(*)
View
15 Library/Homebrew/extend/object.rb
@@ -1,15 +0,0 @@
-class Object
- def instance_exec(*args, &block)
- method_name = :__temp_instance_exec_method
- singleton_class = (class << self; self; end)
- singleton_class.class_eval do
- define_method(method_name, &block)
- end
-
- send(method_name, *args)
- ensure
- singleton_class.class_eval do
- remove_method(method_name) if method_defined?(method_name)
- end
- end unless method_defined?(:instance_exec)
-end
View
1 Library/Homebrew/global.rb
@@ -3,7 +3,6 @@
require 'extend/ARGV'
require 'extend/string'
require 'extend/symbol'
-require 'extend/object'
require 'utils'
require 'exceptions'
require 'set'
View
2 Library/Homebrew/requirement.rb
@@ -68,7 +68,7 @@ def infer_env_modification(o)
when Pathname
self.class.env do
unless ENV["PATH"].split(":").include?(o.parent.to_s)
- append("PATH", o.parent, ":")
+ ENV.append("PATH", o.parent, ":")
end
end
end
View
4 Library/Homebrew/requirements.rb
@@ -179,11 +179,11 @@ def mpi_wrapper_works? compiler
@unknown_langs.empty? and @non_functional.empty?
end
- env do |req|
+ env do
# Set environment variables to help configure scripts find MPI compilers.
# Variable names taken from:
# http://www.gnu.org/software/autoconf-archive/ax_mpi.html
- req.lang_list.each do |lang|
+ @lang_list.each do |lang|
compiler = 'mpi' + lang.to_s
mpi_path = which compiler
View
4 Library/Homebrew/test/test_build_environment.rb
@@ -23,7 +23,7 @@ def test_userpaths?
def test_modify_build_environment
@env << Proc.new { raise StandardError }
assert_raises(StandardError) do
- @env.modify_build_environment
+ @env.modify_build_environment(self)
end
end
@@ -38,7 +38,7 @@ def test_env_block
foo = mock("foo")
@env << Proc.new { foo.some_message }
foo.expects(:some_message)
- @env.modify_build_environment
+ @env.modify_build_environment(self)
end
def test_env_block_with_argument
View
20 Library/Homebrew/test/test_object.rb
@@ -1,20 +0,0 @@
-require 'testing_env'
-require 'extend/object'
-
-class InstanceExecTests < Test::Unit::TestCase
- def test_evaluates_in_context_of_receiver
- assert_equal 1, [1].instance_exec { first }
- end
-
- def test_passes_arguments_to_block
- assert_equal 2, [1].instance_exec(1) { |x| first + x }
- end
-
- def test_does_not_persist_temporary_singleton_method
- obj = Object.new
- before = obj.methods
- obj.instance_exec { methods }
- after = obj.methods
- assert_equal before, after
- end
-end

0 comments on commit d839567

Please sign in to comment.