module Eco module API class MicroCases # Helper to upload target files to `S3`. # @return [Array] the paths in `S3` of the uploaded files. def s3upload_targets # rubocop:disable Metrics/AbcSize [].tap do |paths| session.config.s3storage.target_files.each_with_object(paths) do |file, arr| arr.push(session.s3upload(file: file)) end session.config.s3storage.target_directories.each_with_object(paths) do |folder, arr| arr.concat(session.s3upload(directory: folder)) end session.config.s3storage.target_file_patterns.each_with_object(paths) do |pattern, arr| filenames = [] case pattern when Regexp Dir.entries(".").sort.each do |file| next unless File.file?(file) # Skip directories filenames.push(file) if file =~ pattern end when String Dir.glob(pattern).sort.each do |file| next unless File.file?(file) # Skip directories filenames.push(file) end else # missconfiguration end filenames.each do |file| arr.push(session.s3upload(file: file)) end end end end end end end