Skip to content
Snippets Groups Projects
Commit aca48ded authored by Jack Nagel's avatar Jack Nagel
Browse files

BuildEnvironment: use separate sets for procs and symbols

parent 6b96102f
No related branches found
No related tags found
No related merge requests found
......@@ -3,10 +3,14 @@ require 'set'
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 @@ class BuildEnvironment
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)
......
......@@ -21,8 +21,10 @@ class BuildEnvironmentTests < Test::Unit::TestCase
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% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment