1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2024-12-18 05:21:47 +03:00
mobile-nixos/boot/init/lib/dependencies.rb
2020-02-03 16:19:10 -05:00

51 lines
988 B
Ruby

module Dependencies
class BaseDependency
def fulfilled()
true
end
def name()
self.class.name
end
end
class Boot < BaseDependency
end
class SingletonTask < BaseDependency
def initialize(symbol)
@symbol = symbol
end
def fulfilled()
if Tasks.const_get(@symbol).instance.ran
true
else
$logger.debug(" -> Dependency #{name} unfulfilled (task #{@symbol} hasn't run yet)")
false
end
end
end
class Files < BaseDependency
def initialize(*patterns)
@patterns = *patterns
end
def fulfilled()
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
end
end
end
end