Sha256: b02e458766b07e2c24b2485b9ea9223de6a3cadb95624412699a96ccb72eafb3

Contents?: true

Size: 1.33 KB

Versions: 139

Compression:

Stored size: 1.33 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
        [].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

139 entries across 139 versions & 1 rubygems

Version Path
eco-helpers-2.0.47 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-2.0.46 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-2.0.45 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-2.0.44 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-2.0.43 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-2.0.42 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-2.0.41 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-2.0.40 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-2.0.39 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-2.0.38 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-2.0.37 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-2.0.36 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-2.0.35 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-2.0.34 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-2.0.33 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-2.0.32 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-2.0.31 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-2.0.30 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-2.0.29 lib/eco/api/microcases/s3upload_targets.rb
eco-helpers-2.0.28 lib/eco/api/microcases/s3upload_targets.rb