Sha256: 2a57f2934e3ea093ff4931fc03806a50f3d5ed5e8ea21c7161c4cc51ae560bc8

Contents?: true

Size: 1.37 KB

Versions: 23

Compression:

Stored size: 1.37 KB

Contents

module Eco
  module API
    class MicroCases
      # Helper to upload target files to `S3`.
      # @return [Array<String>] 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

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
eco-helpers-3.0.21 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-3.0.20 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-3.0.19 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-3.0.18 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-3.0.17 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-3.0.16 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-3.0.15 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-3.0.14 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-3.0.13 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-3.0.12 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-3.0.11 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-3.0.10 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-3.0.9 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-3.0.8 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-3.0.7 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-3.0.6 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-3.0.5 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-3.0.4 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-3.0.3 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-3.0.2 lib/eco/api/microcases/s3upload_targets.rb