2019-12-23 06:32:34 +03:00
|
|
|
module Dependencies
|
|
|
|
class BaseDependency
|
|
|
|
def fulfilled()
|
|
|
|
true
|
|
|
|
end
|
2019-12-23 07:12:14 +03:00
|
|
|
|
|
|
|
def name()
|
|
|
|
self.class.name
|
|
|
|
end
|
2019-12-23 06:32:34 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
class Boot < BaseDependency
|
|
|
|
end
|
|
|
|
|
|
|
|
class SingletonTask < BaseDependency
|
|
|
|
def initialize(symbol)
|
|
|
|
@symbol = symbol
|
|
|
|
end
|
2019-12-23 07:12:14 +03:00
|
|
|
|
2019-12-23 06:32:34 +03:00
|
|
|
def fulfilled()
|
2019-12-23 07:12:14 +03:00
|
|
|
if Tasks.const_get(@symbol).instance.ran
|
|
|
|
true
|
|
|
|
else
|
|
|
|
$logger.debug(" -> Dependency #{name} unfulfilled (task #{@symbol} hasn't run yet)")
|
|
|
|
false
|
|
|
|
end
|
2019-12-23 06:32:34 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Files < BaseDependency
|
|
|
|
def initialize(*patterns)
|
|
|
|
@patterns = *patterns
|
|
|
|
end
|
2019-12-23 07:12:14 +03:00
|
|
|
|
2019-12-23 06:32:34 +03:00
|
|
|
def fulfilled()
|
2019-12-23 07:12:14 +03:00
|
|
|
if @patterns.all? { |pattern| Dir.glob(pattern).count > 0 }
|
|
|
|
true
|
|
|
|
else
|
|
|
|
$logger.debug do
|
|
|
|
@patterns.each do |pattern|
|
|
|
|
unless Dir.glob(pattern).count > 0
|
|
|
|
" -> Dependency #{name} unfulfilled (Pattern #{pattern} does not match paths)"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
false
|
2019-12-23 06:32:34 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|