Dir[File.expand_path('*.rb', __dir__)].each { |file| require_relative file } class FileStructure attr_reader :path, :use_glob def initialize(path, use_glob: true) @path = path @use_glob = use_glob end def self.expand(pattern, use_glob: true) if use_glob Dir.glob(pattern).select { |path| File.file?(path) }.map do |path| FileStructure.new(path, use_glob: use_glob) end else [FileStructure.new(pattern, use_glob: use_glob)] end end end class FileStructureValidator < ValidationStrategy def initialize(file) @file = file end def validate(project_path) full_path = File.join(project_path, @file.path) paths = @file.use_glob ? FileStructure.expand(full_path) : [@file] if paths.any? { |path| File.file?(path.path) } Solara.logger.passed("File exists: '#{@file.path}'") else raise ValidationError, "File missing: '#{@file.path}'" end end end