Sha256: f20403ee2584ebf82fb20fbacddbd3769d859fc127247f5313fc6aa24ae6705f

Contents?: true

Size: 849 Bytes

Versions: 8

Compression:

Stored size: 849 Bytes

Contents

# frozen_string_literal: true

module SdrClient
  class RedesignedClient
    # This strategy is for building one file set per set of similarly prefixed uploaded files
    class MatchingFileGroupingStrategy
      # @param [Array<SdrClient::RedesignedClient::DirectUploadResponse>] uploads the uploaded files to attach.
      # @return [Array<Array<SdrClient::RedesignedClient::DirectUploadResponse>>] uploads the grouped uploaded files.
      def self.run(uploads: [])
        # Call `#values` on the result of the grouping operation because:
        #   1) `StructuralGrouper#build_filesets` expects an array of arrays (not hashes); and
        #   2) the keys aren't used anywhere
        uploads.group_by do |ul|
          ::File.join(::File.dirname(ul.filename), ::File.basename(ul.filename, '.*'))
        end.values
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sdr-client-2.18.0 lib/sdr_client/redesigned_client/matching_file_grouping_strategy.rb
sdr-client-2.17.0 lib/sdr_client/redesigned_client/matching_file_grouping_strategy.rb
sdr-client-2.16.0 lib/sdr_client/redesigned_client/matching_file_grouping_strategy.rb
sdr-client-2.13.2 lib/sdr_client/redesigned_client/matching_file_grouping_strategy.rb
sdr-client-2.13.1 lib/sdr_client/redesigned_client/matching_file_grouping_strategy.rb
sdr-client-2.13.0 lib/sdr_client/redesigned_client/matching_file_grouping_strategy.rb
sdr-client-2.13.0.beta2 lib/sdr_client/redesigned_client/matching_file_grouping_strategy.rb
sdr-client-2.13.0.beta1 lib/sdr_client/redesigned_client/matching_file_grouping_strategy.rb