module Jarl # # Load config and application definitions # def self.load abort 'Docker is not installed' unless Docker.installed? if Jarl.jarl_files.empty? abort 'No *.jarl files found' elsif Jarl.applications.empty? abort 'No application definitions found' end true end # # Returns list of found *.jarl files # def self.jarl_files @jarl_files ||= load_jarl_files end # Returns list of registered applications # def self.applications @applications ||= jarl_files.map do |jf| begin jf.applications.map { |app_name, params| Application.new(jf.name, app_name, params) } rescue StandardError => e abort "Failed to parse application definition in file '#{jf.path}': #{e}" end end.flatten end # Returns list of applications matching the pattern # def self.find_applications_by(pattern) applications.select { |a| a.full_name.index(pattern) } end private def self.load_jarl_files Pathname.glob(Pathname.pwd + '**' + '*.jarl').map do |p| JarlFile.new(p) end end end # module Jarl