Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Commit

Permalink
BuildEnvironment: use separate sets for procs and symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
jacknagel committed Feb 25, 2013
1 parent fc9a869 commit 0baac3b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 7 additions & 4 deletions Library/Homebrew/build_environment.rb
Expand Up @@ -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

Expand All @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions Library/Homebrew/test/test_build_environment.rb
Expand Up @@ -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
Expand Down

0 comments on commit 0baac3b

Please sign in to comment.