Browse files

BuildEnvironment: use separate sets for procs and symbols

  • Loading branch information...
1 parent fc9a869 commit 0baac3bf5faa391d0748dccf6b424bfac05c6801 @jacknagel jacknagel committed Feb 25, 2013
Showing with 11 additions and 6 deletions.
  1. +7 −4 Library/Homebrew/build_environment.rb
  2. +4 −2 Library/Homebrew/test/test_build_environment.rb
View
11 Library/Homebrew/build_environment.rb
@@ -3,10 +3,14 @@
class BuildEnvironment
def initialize(*settings)
@settings = Set.new(settings)
+ @procs = Set.new
end
def <<(o)
- @settings << o
+ case o
+ when Proc then @procs << o
+ else @settings << o
+ end
self
end
@@ -19,12 +23,11 @@ def userpaths?
end
def modify_build_environment(context=nil)
- p = @settings.find { |s| Proc === s }
- ENV.instance_exec(context, &p) unless p.nil?
+ @procs.each { |p| ENV.instance_exec(context, &p) }
end
def _dump(*)
- @settings.dup.reject { |s| Proc === s }.join(":")
+ @settings.to_a.join(":")
end
def self._load(s)
View
6 Library/Homebrew/test/test_build_environment.rb
@@ -21,8 +21,10 @@ def test_userpaths?
end
def test_modify_build_environment
- @env << Proc.new { 1 }
- assert_equal 1, @env.modify_build_environment
+ @env << Proc.new { raise StandardError }
+ assert_raises(StandardError) do
+ @env.modify_build_environment
+ end
end
def test_marshal

0 comments on commit 0baac3b

Please sign in to comment.