Dir[File.expand_path('*.rb', __dir__)].each { |file| require_relative file } class DirectoryStructure 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.directory?(path) }.map do |path| DirectoryStructure.new(path, use_glob: use_glob) end else [DirectoryStructure.new(pattern, use_glob: use_glob)] end end end class DirectoryStructureValidator < ValidationStrategy def initialize(dir) @dir = dir end def validate(project_path) full_path = File.join(project_path, @dir.path) paths = @dir.use_glob ? DirectoryStructure.expand(full_path) : [@dir] if paths.any? { |path| File.directory?(path.path) } Solara.logger.passed("Directory exists: '#{@dir.path}'") else raise ValidationError, "Directory missing: '#{@dir.path}'" end end end