Extract task DSL code and spec
This commit is contained in:
@@ -11,20 +11,6 @@ module Producer
|
||||
def evaluate
|
||||
DSL.new &@block
|
||||
end
|
||||
|
||||
|
||||
class DSL
|
||||
ConditionNotMetError = Class.new(StandardError)
|
||||
|
||||
def initialize(&block)
|
||||
instance_eval &block
|
||||
rescue ConditionNotMetError
|
||||
end
|
||||
|
||||
def condition(&block)
|
||||
raise ConditionNotMetError unless block.call
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
18
lib/producer/core/task/dsl.rb
Normal file
18
lib/producer/core/task/dsl.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
module Producer
|
||||
module Core
|
||||
class Task
|
||||
class DSL
|
||||
ConditionNotMetError = Class.new(StandardError)
|
||||
|
||||
def initialize(&block)
|
||||
instance_eval &block
|
||||
rescue ConditionNotMetError
|
||||
end
|
||||
|
||||
def condition(&block)
|
||||
raise ConditionNotMetError unless block.call
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user