Implement tasks condition feature

This commit is contained in:
Thibault Jouan committed 2013-07-28 22:56:08 +00:00
1 parent 16134bf827
commit d146566411
3 files changed
+70 -6

No files matched your search

+15 -1
View File
@@ -9,7 +9,21 @@ module Producer
end
def evaluate
instance_eval &@block
DSL.new &@block
end
class DSL
ConditionNotMetError = Class.new(RuntimeError)
def initialize(&block)
instance_eval &block
rescue ConditionNotMetError
end
def condition(&block)
raise ConditionNotMetError unless block.call
end
end
end
end