mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
BuildEnvironment: use separate sets for procs and symbols
This commit is contained in:
parent
6b96102fad
commit
aca48deda0
@ -3,10 +3,14 @@ require 'set'
|
|||||||
class BuildEnvironment
|
class BuildEnvironment
|
||||||
def initialize(*settings)
|
def initialize(*settings)
|
||||||
@settings = Set.new(settings)
|
@settings = Set.new(settings)
|
||||||
|
@procs = Set.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def <<(o)
|
def <<(o)
|
||||||
@settings << o
|
case o
|
||||||
|
when Proc then @procs << o
|
||||||
|
else @settings << o
|
||||||
|
end
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -19,12 +23,11 @@ class BuildEnvironment
|
|||||||
end
|
end
|
||||||
|
|
||||||
def modify_build_environment(context=nil)
|
def modify_build_environment(context=nil)
|
||||||
p = @settings.find { |s| Proc === s }
|
@procs.each { |p| ENV.instance_exec(context, &p) }
|
||||||
ENV.instance_exec(context, &p) unless p.nil?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def _dump(*)
|
def _dump(*)
|
||||||
@settings.dup.reject { |s| Proc === s }.join(":")
|
@settings.to_a.join(":")
|
||||||
end
|
end
|
||||||
|
|
||||||
def self._load(s)
|
def self._load(s)
|
||||||
|
@ -21,8 +21,10 @@ class BuildEnvironmentTests < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_modify_build_environment
|
def test_modify_build_environment
|
||||||
@env << Proc.new { 1 }
|
@env << Proc.new { raise StandardError }
|
||||||
assert_equal 1, @env.modify_build_environment
|
assert_raises(StandardError) do
|
||||||
|
@env.modify_build_environment
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_marshal
|
def test_marshal
|
||||||
|
Loading…
x
Reference in New Issue
Block a user