Remove proc handling from BuildEnvironment

This commit is contained in:
Jack Nagel 2014-07-07 21:32:36 -05:00
parent d4602b1711
commit 7ee49db51e
2 changed files with 2 additions and 54 deletions

View File

@ -1,8 +1,6 @@
require 'set'
class BuildEnvironment
attr_accessor :proc
def initialize(*settings)
@settings = Set.new(*settings)
end
@ -24,36 +22,11 @@ class BuildEnvironment
def userpaths?
@settings.include? :userpaths
end
def modify_build_environment(receiver)
receiver.instance_eval(&proc) if self.proc
end
def marshal_dump
@settings
end
def marshal_load(data)
@settings = data
end
def _dump(*)
Marshal.dump(marshal_dump)
end
def self._load(s)
new(Marshal.load(s))
end
end
module BuildEnvironmentDSL
def env(*settings, &block)
def env(*settings)
@env ||= BuildEnvironment.new
if block_given?
@env.proc = block
else
@env.merge(settings)
end
@env
@env.merge(settings)
end
end

View File

@ -23,31 +23,6 @@ class BuildEnvironmentTests < Homebrew::TestCase
@env << :userpaths
assert_predicate @env, :userpaths?
end
def test_modify_build_environment
@env.proc = Proc.new { raise StandardError }
assert_raises(StandardError) do
@env.modify_build_environment(self)
end
end
def test_marshal
@env << :userpaths
@env.proc = Proc.new {}
assert_predicate Marshal.load(Marshal.dump(@env)), :userpaths?
end
def test_env_block
error = Class.new(StandardError)
@env.proc = Proc.new { raise error }
assert_raises(error) { @env.modify_build_environment(self) }
end
def test_env_block_with_argument
error = Class.new(StandardError)
@env.proc = Proc.new { |x| raise x }
assert_raises(error) { @env.modify_build_environment(error) }
end
end
class BuildEnvironmentDSLTests < Homebrew::TestCase